diff options
author | Robert Speicher <rspeicher@gmail.com> | 2016-01-04 18:56:48 -0500 |
---|---|---|
committer | Robert Speicher <rspeicher@gmail.com> | 2016-01-04 18:59:25 -0500 |
commit | 01248d205103fe6c408e914e8943873ceb7acb2a (patch) | |
tree | 6f3e6e8b7abf80d0f67ee1fd98437a9b07053966 /spec/mailers | |
parent | 0e60282e36faab8b0f4faee0b71716987df28416 (diff) | |
download | gitlab-ce-01248d205103fe6c408e914e8943873ceb7acb2a.tar.gz |
Make AbuseReportMailer responsible for knowing if it should deliver
Diffstat (limited to 'spec/mailers')
-rw-r--r-- | spec/mailers/abuse_report_mailer_spec.rb | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/spec/mailers/abuse_report_mailer_spec.rb b/spec/mailers/abuse_report_mailer_spec.rb new file mode 100644 index 00000000000..eb433c38873 --- /dev/null +++ b/spec/mailers/abuse_report_mailer_spec.rb @@ -0,0 +1,38 @@ +require 'rails_helper' + +describe AbuseReportMailer do + include EmailSpec::Matchers + + describe '.notify' do + context 'with admin_notification_email set' do + before do + stub_application_setting(admin_notification_email: 'admin@example.com') + end + + it 'sends to the admin_notification_email' do + report = create(:abuse_report) + + mail = described_class.notify(report.id) + + expect(mail).to deliver_to 'admin@example.com' + end + + it 'includes the user in the subject' do + report = create(:abuse_report) + + mail = described_class.notify(report.id) + + expect(mail).to have_subject "#{report.user.name} (#{report.user.username}) was reported for abuse" + end + end + + context 'with no admin_notification_email set' do + it 'returns early' do + stub_application_setting(admin_notification_email: nil) + + expect { described_class.notify(spy).deliver_now }. + not_to change { ActionMailer::Base.deliveries.count } + end + end + end +end |