Commit 5345be35 authored by Corinna Wiesner's avatar Corinna Wiesner Committed by Markus Koller

Add specs for not sending user cap email

Specs for not sending the user cap email when the user cap is set to nil
or hasn't not been reached yet were missing. This change will add these.
parent 14c54040
......@@ -23,7 +23,7 @@ RSpec.describe SetUserStatusBasedOnUserCapSettingWorker, type: :worker do
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(:inactive_admin) { create(:user, :admin, :deactivated) }
......@@ -34,6 +34,16 @@ RSpec.describe SetUserStatusBasedOnUserCapSettingWorker, type: :worker do
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
let(:user) { active_user }
......@@ -52,6 +62,8 @@ RSpec.describe SetUserStatusBasedOnUserCapSettingWorker, type: :worker do
expect(user.reload).to be_blocked_pending_approval
end
include_examples 'does not send emails to active admins'
end
context 'when current billable user count is less than user cap' do
......@@ -66,6 +78,8 @@ RSpec.describe SetUserStatusBasedOnUserCapSettingWorker, type: :worker do
expect { subject }.to have_enqueued_mail(DeviseMailer, :user_admin_approval)
end
include_examples 'does not send emails to active admins'
context 'when user has not confirmed their email yet' do
let(:user) { create(:user, :blocked_pending_approval, :unconfirmed) }
......@@ -120,7 +134,7 @@ RSpec.describe SetUserStatusBasedOnUserCapSettingWorker, type: :worker do
let(:new_user_signups_cap) { 2 }
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
context 'when current billable user count is greater than user cap' do
......@@ -129,7 +143,7 @@ RSpec.describe SetUserStatusBasedOnUserCapSettingWorker, type: :worker do
let(:new_user_signups_cap) { 1 }
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
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