diff options
Diffstat (limited to 'spec/services')
-rw-r--r-- | spec/services/notification_recipients/build_service_spec.rb | 102 |
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 |