FIX: Do not send staff welcome message if user already has role

This commit is contained in:
David Taylor
2020-06-17 12:12:55 +01:00
parent 9da3a7f436
commit 6caad5c083
2 changed files with 26 additions and 0 deletions

View File

@ -164,6 +164,30 @@ describe User do
end
end
context 'enqueue_staff_welcome_message' do
let!(:first_admin) { Fabricate(:admin) }
let(:user) { Fabricate(:user) }
it 'enqueues message for admin' do
expect {
user.grant_admin!
}.to change { Jobs::SendSystemMessage.jobs.count }.by 1
end
it 'enqueues message for moderator' do
expect {
user.grant_moderation!
}.to change { Jobs::SendSystemMessage.jobs.count }.by 1
end
it 'skips the message if already an admin' do
user.update(admin: true)
expect {
user.grant_admin!
}.to change { Jobs::SendSystemMessage.jobs.count }.by 0
end
end
context '.set_default_tags_preferences' do
let(:tag) { Fabricate(:tag) }