diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-10-05 16:54:15 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-10-05 16:54:15 +0300 |
commit | be834a25982746ffd85252ff502df42bb88cb9d5 (patch) | |
tree | b4d6a8ba0931e12fac08f05abea33a3b8ec2c8a2 /spec/lib/gitlab/sql/pattern_spec.rb | |
parent | ee925a3597f27e92f83a50937a64068109675b3d (diff) |
Add latest changes from gitlab-org/gitlab@13-5-stable-eev13.5.0-rc32
Diffstat (limited to 'spec/lib/gitlab/sql/pattern_spec.rb')
-rw-r--r-- | spec/lib/gitlab/sql/pattern_spec.rb | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/spec/lib/gitlab/sql/pattern_spec.rb b/spec/lib/gitlab/sql/pattern_spec.rb index 220ac2ff6da..9bf6f0b82bc 100644 --- a/spec/lib/gitlab/sql/pattern_spec.rb +++ b/spec/lib/gitlab/sql/pattern_spec.rb @@ -3,6 +3,43 @@ require 'spec_helper' RSpec.describe Gitlab::SQL::Pattern do + using RSpec::Parameterized::TableSyntax + + describe '.fuzzy_search' do + let_it_be(:issue1) { create(:issue, title: 'noise foo noise', description: 'noise bar noise') } + let_it_be(:issue2) { create(:issue, title: 'noise baz noise', description: 'noise foo noise') } + let_it_be(:issue3) { create(:issue, title: 'Oh', description: 'Ah') } + + subject(:fuzzy_search) { Issue.fuzzy_search(query, columns) } + + where(:query, :columns, :expected) do + 'foo' | [Issue.arel_table[:title]] | %i[issue1] + + 'foo' | %i[title] | %i[issue1] + 'foo' | %w[title] | %i[issue1] + 'foo' | %i[description] | %i[issue2] + 'foo' | %i[title description] | %i[issue1 issue2] + 'bar' | %i[title description] | %i[issue1] + 'baz' | %i[title description] | %i[issue2] + 'qux' | %i[title description] | [] + + 'oh' | %i[title description] | %i[issue3] + 'OH' | %i[title description] | %i[issue3] + 'ah' | %i[title description] | %i[issue3] + 'AH' | %i[title description] | %i[issue3] + 'oh' | %i[title] | %i[issue3] + 'ah' | %i[description] | %i[issue3] + end + + with_them do + let(:expected_issues) { expected.map { |sym| send(sym) } } + + it 'finds the expected issues' do + expect(fuzzy_search).to match_array(expected_issues) + end + end + end + describe '.to_pattern' do subject(:to_pattern) { User.to_pattern(query) } |