FIX: Improve error messages if user cannot send PM emails (#12547)

This commit is contained in:
Bianca Nenciu
2021-03-30 12:18:57 +03:00
committed by GitHub
parent 21b4fef175
commit 52a5c7e438
4 changed files with 14 additions and 2 deletions

View File

@@ -245,6 +245,17 @@ describe TopicCreator do
end.to raise_error(ActiveRecord::Rollback)
end
end
context 'to emails' do
it 'works for staff' do
expect(TopicCreator.create(admin, Guardian.new(admin), pm_valid_attrs.merge(target_emails: 'test@example.com'))).to be_valid
end
it 'does not work for non-staff' do
user.update!(trust_level: TrustLevel[4])
expect { TopicCreator.create(user, Guardian.new(user), pm_valid_attrs.merge(target_emails: 'test@example.com')) }.to raise_error(ActiveRecord::Rollback)
end
end
end
context 'setting timestamps' do