summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDouwe Maan <douwe@selenight.nl>2017-11-24 12:08:16 +0100
committerDouwe Maan <douwe@selenight.nl>2017-11-24 17:28:50 +0100
commitb2c5363da1bdfb4df8693de38f9d83fe203e6e99 (patch)
tree9aea4618ab6081d51e977091a6d456d635496129
parentaedd2cfa5b82c01f82ec26b64880fce2a07fe942 (diff)
downloadgitlab-ce-b2c5363da1bdfb4df8693de38f9d83fe203e6e99.tar.gz
Rename to_fuzzy_arel to fuzzy_arel_match
-rw-r--r--app/models/concerns/issuable.rb6
-rw-r--r--lib/gitlab/sql/pattern.rb2
-rw-r--r--spec/lib/gitlab/sql/pattern_spec.rb12
3 files changed, 10 insertions, 10 deletions
diff --git a/app/models/concerns/issuable.rb b/app/models/concerns/issuable.rb
index e607707475f..176ce1152f1 100644
--- a/app/models/concerns/issuable.rb
+++ b/app/models/concerns/issuable.rb
@@ -122,7 +122,7 @@ module Issuable
#
# Returns an ActiveRecord::Relation.
def search(query)
- title = to_fuzzy_arel(:title, query)
+ title = fuzzy_arel_match(:title, query)
where(title)
end
@@ -135,8 +135,8 @@ module Issuable
#
# Returns an ActiveRecord::Relation.
def full_search(query)
- title = to_fuzzy_arel(:title, query)
- description = to_fuzzy_arel(:description, query)
+ title = fuzzy_arel_match(:title, query)
+ description = fuzzy_arel_match(:description, query)
where(title&.or(description))
end
diff --git a/lib/gitlab/sql/pattern.rb b/lib/gitlab/sql/pattern.rb
index 7c2d1d8f887..8741aa0f1c4 100644
--- a/lib/gitlab/sql/pattern.rb
+++ b/lib/gitlab/sql/pattern.rb
@@ -19,7 +19,7 @@ module Gitlab
query.length >= MIN_CHARS_FOR_PARTIAL_MATCHING
end
- def to_fuzzy_arel(column, query)
+ def fuzzy_arel_match(column, query)
words = select_fuzzy_words(query)
matches = words.map { |word| arel_table[column].matches(to_pattern(word)) }
diff --git a/spec/lib/gitlab/sql/pattern_spec.rb b/spec/lib/gitlab/sql/pattern_spec.rb
index 48d56628ed5..d2989489e49 100644
--- a/spec/lib/gitlab/sql/pattern_spec.rb
+++ b/spec/lib/gitlab/sql/pattern_spec.rb
@@ -137,14 +137,14 @@ describe Gitlab::SQL::Pattern do
end
end
- describe '.to_fuzzy_arel' do
- subject(:to_fuzzy_arel) { Issue.to_fuzzy_arel(:title, query) }
+ describe '.fuzzy_arel_match' do
+ subject(:fuzzy_arel_match) { Issue.fuzzy_arel_match(:title, query) }
context 'with a word equal to 3 chars' do
let(:query) { 'foo' }
it 'returns a single ILIKE condition' do
- expect(to_fuzzy_arel.to_sql).to match(/title.*I?LIKE '\%foo\%'/)
+ expect(fuzzy_arel_match.to_sql).to match(/title.*I?LIKE '\%foo\%'/)
end
end
@@ -152,7 +152,7 @@ describe Gitlab::SQL::Pattern do
let(:query) { 'fo' }
it 'returns nil' do
- expect(to_fuzzy_arel).to be_nil
+ expect(fuzzy_arel_match).to be_nil
end
end
@@ -160,7 +160,7 @@ describe Gitlab::SQL::Pattern do
let(:query) { 'foo baz' }
it 'returns a joining LIKE condition using a AND' do
- expect(to_fuzzy_arel.to_sql).to match(/title.+I?LIKE '\%foo\%' AND .*title.*I?LIKE '\%baz\%'/)
+ expect(fuzzy_arel_match.to_sql).to match(/title.+I?LIKE '\%foo\%' AND .*title.*I?LIKE '\%baz\%'/)
end
end
@@ -168,7 +168,7 @@ describe Gitlab::SQL::Pattern do
let(:query) { 'foo "really bar" baz' }
it 'returns a joining LIKE condition using a AND' do
- expect(to_fuzzy_arel.to_sql).to match(/title.+I?LIKE '\%foo\%' AND .*title.*I?LIKE '\%baz\%' AND .*title.*I?LIKE '\%really bar\%'/)
+ expect(fuzzy_arel_match.to_sql).to match(/title.+I?LIKE '\%foo\%' AND .*title.*I?LIKE '\%baz\%' AND .*title.*I?LIKE '\%really bar\%'/)
end
end
end