summaryrefslogtreecommitdiff
path: root/spec/lib/gitlab/sql
diff options
context:
space:
mode:
authorDouwe Maan <douwe@selenight.nl>2017-11-24 12:23:47 +0100
committerDouwe Maan <douwe@selenight.nl>2017-11-27 11:29:40 +0100
commitd4eea275310867eccc927d0e92a1d19a165f0668 (patch)
tree2909c3b95d69aadfd6dba5a3d9f2e18132960db8 /spec/lib/gitlab/sql
parentb2c5363da1bdfb4df8693de38f9d83fe203e6e99 (diff)
downloadgitlab-ce-d4eea275310867eccc927d0e92a1d19a165f0668.tar.gz
Modify fuzzy_arel_match to search for equality when a term shorter than 3 characters is provided
Diffstat (limited to 'spec/lib/gitlab/sql')
-rw-r--r--spec/lib/gitlab/sql/pattern_spec.rb20
1 files changed, 18 insertions, 2 deletions
diff --git a/spec/lib/gitlab/sql/pattern_spec.rb b/spec/lib/gitlab/sql/pattern_spec.rb
index d2989489e49..ef51e3cc8df 100644
--- a/spec/lib/gitlab/sql/pattern_spec.rb
+++ b/spec/lib/gitlab/sql/pattern_spec.rb
@@ -151,8 +151,8 @@ describe Gitlab::SQL::Pattern do
context 'with a word shorter than 3 chars' do
let(:query) { 'fo' }
- it 'returns nil' do
- expect(fuzzy_arel_match).to be_nil
+ it 'returns a single equality condition' do
+ expect(fuzzy_arel_match.to_sql).to match(/title.*I?LIKE 'fo'/)
end
end
@@ -164,6 +164,22 @@ describe Gitlab::SQL::Pattern do
end
end
+ context 'with two words both shorter than 3 chars' do
+ let(:query) { 'fo ba' }
+
+ it 'returns a single ILIKE condition' do
+ expect(fuzzy_arel_match.to_sql).to match(/title.*I?LIKE 'fo ba'/)
+ end
+ end
+
+ context 'with two words, one shorter 3 chars' do
+ let(:query) { 'foo ba' }
+
+ it 'returns a single ILIKE condition using the longer word' do
+ expect(fuzzy_arel_match.to_sql).to match(/title.+I?LIKE '\%foo\%'/)
+ end
+ end
+
context 'with a multi-word surrounded by double quote and two words' do
let(:query) { 'foo "really bar" baz' }