diff options
author | Sean McGivern <sean@gitlab.com> | 2019-03-01 09:17:29 +0000 |
---|---|---|
committer | Sean McGivern <sean@gitlab.com> | 2019-03-01 09:17:29 +0000 |
commit | d860ab195afbf11118564e6399cd59a8bbd9d622 (patch) | |
tree | 70f4111245b1796d23cb21fcb75a26253dadf063 /spec | |
parent | d86de642d16e0f7518c7f508b5282c89128e9a58 (diff) | |
parent | 39afba065970bc5482589039e9e93c04f0c9285f (diff) | |
download | gitlab-ce-d860ab195afbf11118564e6399cd59a8bbd9d622.tar.gz |
Merge branch '54643-lower_issuable_finder_complexity' into 'master'
IssuableFinder - Always use CTE for group counts
Closes #54643
See merge request gitlab-org/gitlab-ce!25411
Diffstat (limited to 'spec')
-rw-r--r-- | spec/controllers/groups_controller_spec.rb | 4 | ||||
-rw-r--r-- | spec/finders/issues_finder_spec.rb | 55 |
2 files changed, 26 insertions, 33 deletions
diff --git a/spec/controllers/groups_controller_spec.rb b/spec/controllers/groups_controller_spec.rb index 7d87b33e503..21e5122c06b 100644 --- a/spec/controllers/groups_controller_spec.rb +++ b/spec/controllers/groups_controller_spec.rb @@ -227,9 +227,7 @@ describe GroupsController do context 'searching' do before do - # Remove in https://gitlab.com/gitlab-org/gitlab-ce/issues/54643 - stub_feature_flags(use_cte_for_group_issues_search: false) - stub_feature_flags(use_subquery_for_group_issues_search: true) + stub_feature_flags(attempt_group_search_optimizations: true) end it 'works with popularity sort' do diff --git a/spec/finders/issues_finder_spec.rb b/spec/finders/issues_finder_spec.rb index 47e2548c3d6..55efab7dec3 100644 --- a/spec/finders/issues_finder_spec.rb +++ b/spec/finders/issues_finder_spec.rb @@ -715,7 +715,7 @@ describe IssuesFinder do before do allow(Gitlab::Database).to receive(:postgresql?).and_return(true) - stub_feature_flags(use_subquery_for_group_issues_search: true) + stub_feature_flags(attempt_group_search_optimizations: true) end context 'when there is no search param' do @@ -746,11 +746,11 @@ describe IssuesFinder do end end - context 'when the use_subquery_for_group_issues_search flag is disabled' do + context 'when the attempt_group_search_optimizations flag is disabled' do let(:params) { { search: 'foo', attempt_group_search_optimizations: true } } before do - stub_feature_flags(use_subquery_for_group_issues_search: false) + stub_feature_flags(attempt_group_search_optimizations: false) end it 'returns false' do @@ -758,6 +758,14 @@ describe IssuesFinder do end end + context 'when force_cte? is true' do + let(:params) { { search: 'foo', attempt_group_search_optimizations: true, force_cte: true } } + + it 'returns false' do + expect(finder.use_subquery_for_search?).to be_falsey + end + end + context 'when all conditions are met' do let(:params) { { search: 'foo', attempt_group_search_optimizations: true } } @@ -767,72 +775,59 @@ describe IssuesFinder do end end - describe '#use_cte_for_search?' do + describe '#use_cte_for_count?' do let(:finder) { described_class.new(nil, params) } before do allow(Gitlab::Database).to receive(:postgresql?).and_return(true) - stub_feature_flags(use_cte_for_group_issues_search: true) - stub_feature_flags(use_subquery_for_group_issues_search: false) + stub_feature_flags(attempt_group_search_optimizations: true) end context 'when there is no search param' do - let(:params) { { attempt_group_search_optimizations: true } } + let(:params) { { attempt_group_search_optimizations: true, force_cte: true } } it 'returns false' do - expect(finder.use_cte_for_search?).to be_falsey + expect(finder.use_cte_for_count?).to be_falsey end end context 'when the database is not Postgres' do - let(:params) { { search: 'foo', attempt_group_search_optimizations: true } } + let(:params) { { search: 'foo', force_cte: true, attempt_group_search_optimizations: true } } before do allow(Gitlab::Database).to receive(:postgresql?).and_return(false) end it 'returns false' do - expect(finder.use_cte_for_search?).to be_falsey + expect(finder.use_cte_for_count?).to be_falsey end end - context 'when the attempt_group_search_optimizations param is falsey' do + context 'when the force_cte param is falsey' do let(:params) { { search: 'foo' } } it 'returns false' do - expect(finder.use_cte_for_search?).to be_falsey - end - end - - context 'when the use_cte_for_group_issues_search flag is disabled' do - let(:params) { { search: 'foo', attempt_group_search_optimizations: true } } - - before do - stub_feature_flags(use_cte_for_group_issues_search: false) - end - - it 'returns false' do - expect(finder.use_cte_for_search?).to be_falsey + expect(finder.use_cte_for_count?).to be_falsey end end - context 'when use_subquery_for_search? is true' do - let(:params) { { search: 'foo', attempt_group_search_optimizations: true } } + context 'when the attempt_group_search_optimizations flag is disabled' do + let(:params) { { search: 'foo', force_cte: true, attempt_group_search_optimizations: true } } before do - stub_feature_flags(use_subquery_for_group_issues_search: true) + stub_feature_flags(attempt_group_search_optimizations: false) end it 'returns false' do - expect(finder.use_cte_for_search?).to be_falsey + expect(finder.use_cte_for_count?).to be_falsey end end context 'when all conditions are met' do - let(:params) { { search: 'foo', attempt_group_search_optimizations: true } } + let(:params) { { search: 'foo', force_cte: true, attempt_group_search_optimizations: true } } it 'returns true' do - expect(finder.use_cte_for_search?).to be_truthy + expect(finder.use_cte_for_count?).to be_truthy end end end |