summaryrefslogtreecommitdiff
path: root/spec/services
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2022-06-15 21:10:04 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2022-06-15 21:10:04 +0000
commitec3e75cfeadc943e3fc63ac5e6b5504ad43ea512 (patch)
tree79bc910fc137d5c46d6670a98e74a0438486f0bf /spec/services
parent36b47b4bd3eb88b08323cb26f5863e1dacdb18b7 (diff)
downloadgitlab-ce-ec3e75cfeadc943e3fc63ac5e6b5504ad43ea512.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/services')
-rw-r--r--spec/services/notification_recipients/build_service_spec.rb102
1 files changed, 42 insertions, 60 deletions
diff --git a/spec/services/notification_recipients/build_service_spec.rb b/spec/services/notification_recipients/build_service_spec.rb
index b348d95ecfc..899d23ec641 100644
--- a/spec/services/notification_recipients/build_service_spec.rb
+++ b/spec/services/notification_recipients/build_service_spec.rb
@@ -15,7 +15,7 @@ RSpec.describe NotificationRecipients::BuildService do
shared_examples 'no N+1 queries' do
it 'avoids N+1 queries', :request_store do
# existing N+1 due to multiple users having to be looked up in the project_authorizations table
- threshold = Feature.enabled?(:faster_owner_access) && project.private? ? 1 : 0
+ threshold = project.private? ? 1 : 0
create_user
@@ -31,42 +31,33 @@ RSpec.describe NotificationRecipients::BuildService do
end
end
- [true, false].each do |value|
- context "when faster_owner_access feature is #{value ? 'enabled' : 'not enabled'}" do
- before do
- # test both feature flag values
- stub_feature_flags(faster_owner_access: value)
- end
-
- context 'when there are multiple watchers' do
- def create_user
- watcher = create(:user)
- create(:notification_setting, source: project, user: watcher, level: :watch)
+ context 'when there are multiple watchers' do
+ def create_user
+ watcher = create(:user)
+ create(:notification_setting, source: project, user: watcher, level: :watch)
- other_projects.each do |other_project|
- create(:notification_setting, source: other_project, user: watcher, level: :watch)
- end
- end
-
- include_examples 'no N+1 queries'
+ other_projects.each do |other_project|
+ create(:notification_setting, source: other_project, user: watcher, level: :watch)
end
+ end
- context 'when there are multiple subscribers' do
- def create_user
- subscriber = create(:user)
- issue.subscriptions.create!(user: subscriber, project: project, subscribed: true)
- end
+ include_examples 'no N+1 queries'
+ end
- include_examples 'no N+1 queries'
+ context 'when there are multiple subscribers' do
+ def create_user
+ subscriber = create(:user)
+ issue.subscriptions.create!(user: subscriber, project: project, subscribed: true)
+ end
- context 'when the project is private' do
- before do
- project.update!(visibility_level: Gitlab::VisibilityLevel::PRIVATE)
- end
+ include_examples 'no N+1 queries'
- include_examples 'no N+1 queries'
- end
+ context 'when the project is private' do
+ before do
+ project.update!(visibility_level: Gitlab::VisibilityLevel::PRIVATE)
end
+
+ include_examples 'no N+1 queries'
end
end
end
@@ -79,7 +70,7 @@ RSpec.describe NotificationRecipients::BuildService do
shared_examples 'no N+1 queries' do
it 'avoids N+1 queries', :request_store do
# existing N+1 due to multiple users having to be looked up in the project_authorizations table
- threshold = Feature.enabled?(:faster_owner_access) && project.private? ? 1 : 0
+ threshold = project.private? ? 1 : 0
create_user
@@ -95,42 +86,33 @@ RSpec.describe NotificationRecipients::BuildService do
end
end
- [true, false].each do |value|
- context "when faster_owner_access feature is #{value ? 'enabled' : 'not enabled'}" do
- before do
- # test both feature flag values
- stub_feature_flags(faster_owner_access: value)
- end
-
- context 'when there are multiple watchers' do
- def create_user
- watcher = create(:user)
- create(:notification_setting, source: project, user: watcher, level: :watch)
+ context 'when there are multiple watchers' do
+ def create_user
+ watcher = create(:user)
+ create(:notification_setting, source: project, user: watcher, level: :watch)
- other_projects.each do |other_project|
- create(:notification_setting, source: other_project, user: watcher, level: :watch)
- end
- end
-
- include_examples 'no N+1 queries'
+ other_projects.each do |other_project|
+ create(:notification_setting, source: other_project, user: watcher, level: :watch)
end
+ end
- context 'when there are multiple subscribers' do
- def create_user
- subscriber = create(:user)
- merge_request.subscriptions.create!(user: subscriber, project: project, subscribed: true)
- end
+ include_examples 'no N+1 queries'
+ end
- include_examples 'no N+1 queries'
+ context 'when there are multiple subscribers' do
+ def create_user
+ subscriber = create(:user)
+ merge_request.subscriptions.create!(user: subscriber, project: project, subscribed: true)
+ end
- context 'when the project is private' do
- before do
- project.update!(visibility_level: Gitlab::VisibilityLevel::PRIVATE)
- end
+ include_examples 'no N+1 queries'
- include_examples 'no N+1 queries'
- end
+ context 'when the project is private' do
+ before do
+ project.update!(visibility_level: Gitlab::VisibilityLevel::PRIVATE)
end
+
+ include_examples 'no N+1 queries'
end
end
end