Commit 011d836d authored by Markus Koller's avatar Markus Koller

Merge branch '321956_add_specs_for_not_sending_user_cap_email' into 'master'

Add specs for not sending user cap email

See merge request gitlab-org/gitlab!54542
parents cad535ba 5345be35
...@@ -23,7 +23,7 @@ RSpec.describe SetUserStatusBasedOnUserCapSettingWorker, type: :worker do ...@@ -23,7 +23,7 @@ RSpec.describe SetUserStatusBasedOnUserCapSettingWorker, type: :worker do
end end
end end
shared_examples 'sends email to every active admin' do shared_examples 'sends emails to every active admin' do
let_it_be(:active_admin) { create(:user, :admin, state: 'active') } let_it_be(:active_admin) { create(:user, :admin, state: 'active') }
let_it_be(:inactive_admin) { create(:user, :admin, :deactivated) } let_it_be(:inactive_admin) { create(:user, :admin, :deactivated) }
...@@ -34,6 +34,16 @@ RSpec.describe SetUserStatusBasedOnUserCapSettingWorker, type: :worker do ...@@ -34,6 +34,16 @@ RSpec.describe SetUserStatusBasedOnUserCapSettingWorker, type: :worker do
end end
end end
shared_examples 'does not send emails to active admins' do
let_it_be(:active_admin) { create(:user, :admin, state: 'active') }
it 'does not send an email to active admins' do
expect(::Notify).not_to receive(:user_cap_reached)
subject
end
end
context 'when user is not blocked_pending_approval' do context 'when user is not blocked_pending_approval' do
let(:user) { active_user } let(:user) { active_user }
...@@ -52,6 +62,8 @@ RSpec.describe SetUserStatusBasedOnUserCapSettingWorker, type: :worker do ...@@ -52,6 +62,8 @@ RSpec.describe SetUserStatusBasedOnUserCapSettingWorker, type: :worker do
expect(user.reload).to be_blocked_pending_approval expect(user.reload).to be_blocked_pending_approval
end end
include_examples 'does not send emails to active admins'
end end
context 'when current billable user count is less than user cap' do context 'when current billable user count is less than user cap' do
...@@ -66,6 +78,8 @@ RSpec.describe SetUserStatusBasedOnUserCapSettingWorker, type: :worker do ...@@ -66,6 +78,8 @@ RSpec.describe SetUserStatusBasedOnUserCapSettingWorker, type: :worker do
expect { subject }.to have_enqueued_mail(DeviseMailer, :user_admin_approval) expect { subject }.to have_enqueued_mail(DeviseMailer, :user_admin_approval)
end end
include_examples 'does not send emails to active admins'
context 'when user has not confirmed their email yet' do context 'when user has not confirmed their email yet' do
let(:user) { create(:user, :blocked_pending_approval, :unconfirmed) } let(:user) { create(:user, :blocked_pending_approval, :unconfirmed) }
...@@ -120,7 +134,7 @@ RSpec.describe SetUserStatusBasedOnUserCapSettingWorker, type: :worker do ...@@ -120,7 +134,7 @@ RSpec.describe SetUserStatusBasedOnUserCapSettingWorker, type: :worker do
let(:new_user_signups_cap) { 2 } let(:new_user_signups_cap) { 2 }
include_examples 'keeps user in blocked_pending_approval state' include_examples 'keeps user in blocked_pending_approval state'
include_examples 'sends email to every active admin' include_examples 'sends emails to every active admin'
end end
context 'when current billable user count is greater than user cap' do context 'when current billable user count is greater than user cap' do
...@@ -129,7 +143,7 @@ RSpec.describe SetUserStatusBasedOnUserCapSettingWorker, type: :worker do ...@@ -129,7 +143,7 @@ RSpec.describe SetUserStatusBasedOnUserCapSettingWorker, type: :worker do
let(:new_user_signups_cap) { 1 } let(:new_user_signups_cap) { 1 }
include_examples 'keeps user in blocked_pending_approval state' include_examples 'keeps user in blocked_pending_approval state'
include_examples 'sends email to every active admin' include_examples 'sends emails to every active admin'
end end
end end
end end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment