diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-09-20 16:18:24 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-09-20 16:18:24 +0300 |
commit | 0653e08efd039a5905f3fa4f6e9cef9f5d2f799c (patch) | |
tree | 4dcc884cf6d81db44adae4aa99f8ec1233a41f55 /spec/support_specs/database/prevent_cross_joins_spec.rb | |
parent | 744144d28e3e7fddc117924fef88de5d9674fe4c (diff) |
Add latest changes from gitlab-org/gitlab@14-3-stable-eev14.3.0-rc42
Diffstat (limited to 'spec/support_specs/database/prevent_cross_joins_spec.rb')
-rw-r--r-- | spec/support_specs/database/prevent_cross_joins_spec.rb | 28 |
1 files changed, 19 insertions, 9 deletions
diff --git a/spec/support_specs/database/prevent_cross_joins_spec.rb b/spec/support_specs/database/prevent_cross_joins_spec.rb index dd4ed9c40b8..e9a95fe77a5 100644 --- a/spec/support_specs/database/prevent_cross_joins_spec.rb +++ b/spec/support_specs/database/prevent_cross_joins_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' RSpec.describe Database::PreventCrossJoins do - context 'when running in :prevent_cross_joins scope', :prevent_cross_joins do + context 'when running in a default scope' do context 'when only non-CI tables are used' do it 'does not raise exception' do expect { main_only_query }.not_to raise_error @@ -24,23 +24,33 @@ RSpec.describe Database::PreventCrossJoins do context 'when allow_cross_joins_across_databases is used' do it 'does not raise exception' do - Gitlab::Database.allow_cross_joins_across_databases(url: 'http://issue-url') + expect { main_and_ci_query_allowlisted }.not_to raise_error + end + end - expect { main_and_ci_query }.not_to raise_error + context 'when allow_cross_joins_across_databases is used' do + it 'does not raise exception' do + expect { main_and_ci_query_allowlist_nested }.not_to raise_error end end end end - context 'when running in a default scope' do - context 'when CI and non-CI tables are used' do - it 'does not raise exception' do - expect { main_and_ci_query }.not_to raise_error - end + private + + def main_and_ci_query_allowlisted + Gitlab::Database.allow_cross_joins_across_databases(url: 'http://issue-url') do + main_and_ci_query end end - private + def main_and_ci_query_allowlist_nested + Gitlab::Database.allow_cross_joins_across_databases(url: 'http://issue-url') do + main_and_ci_query_allowlisted + + main_and_ci_query + end + end def main_only_query Issue.joins(:project).last |