diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-09-29 18:11:47 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-09-29 18:11:47 +0300 |
commit | cee701c9641a4dfa508f9a1d913863a52ae67167 (patch) | |
tree | 64ae2ab0eebdd56b8656ddc577c1bdee367bcbfe /spec/finders | |
parent | 5f8d4d631d241c993c2cac54db3494f474b21dc1 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/finders')
-rw-r--r-- | spec/finders/issues_finder_spec.rb | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/spec/finders/issues_finder_spec.rb b/spec/finders/issues_finder_spec.rb index ed35d75720c..9f12308013e 100644 --- a/spec/finders/issues_finder_spec.rb +++ b/spec/finders/issues_finder_spec.rb @@ -1199,6 +1199,14 @@ RSpec.describe IssuesFinder do end end + context 'when a non-simple sort is given' do + let(:params) { { search: 'foo', attempt_project_search_optimizations: true, sort: 'popularity' } } + + it 'returns false' do + expect(finder.use_cte_for_search?).to be_falsey + end + end + context 'when all conditions are met' do context "uses group search optimization" do let(:params) { { search: 'foo', attempt_group_search_optimizations: true } } @@ -1217,6 +1225,24 @@ RSpec.describe IssuesFinder do expect(finder.execute.to_sql).to match(/^WITH "issues" AS #{Gitlab::Database::AsWithMaterialized.materialized_if_supported}/) end end + + context 'with simple sort' do + let(:params) { { search: 'foo', attempt_project_search_optimizations: true, sort: 'updated_desc' } } + + it 'returns true' do + expect(finder.use_cte_for_search?).to be_truthy + expect(finder.execute.to_sql).to match(/^WITH "issues" AS #{Gitlab::Database::AsWithMaterialized.materialized_if_supported}/) + end + end + + context 'with simple sort as a symbol' do + let(:params) { { search: 'foo', attempt_project_search_optimizations: true, sort: :updated_desc } } + + it 'returns true' do + expect(finder.use_cte_for_search?).to be_truthy + expect(finder.execute.to_sql).to match(/^WITH "issues" AS #{Gitlab::Database::AsWithMaterialized.materialized_if_supported}/) + end + end end end |