2019-10-21 05:06:22 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2019-08-29 03:56:52 -04:00
|
|
|
require 'spec_helper'
|
2016-01-04 18:56:48 -05:00
|
|
|
|
2020-06-24 14:09:03 -04:00
|
|
|
RSpec.describe AbuseReportMailer do
|
2016-01-04 18:56:48 -05:00
|
|
|
include EmailSpec::Matchers
|
|
|
|
|
|
|
|
describe '.notify' do
|
2019-02-20 10:18:15 -05:00
|
|
|
before do
|
|
|
|
stub_application_setting(admin_notification_email: 'admin@example.com')
|
|
|
|
end
|
2016-01-04 18:56:48 -05:00
|
|
|
|
2019-02-20 10:18:15 -05:00
|
|
|
let(:report) { create(:abuse_report) }
|
|
|
|
|
|
|
|
subject { described_class.notify(report.id) }
|
2016-01-04 18:56:48 -05:00
|
|
|
|
2019-02-20 10:18:15 -05:00
|
|
|
it_behaves_like 'appearance header and footer enabled'
|
|
|
|
it_behaves_like 'appearance header and footer not enabled'
|
2016-01-04 18:56:48 -05:00
|
|
|
|
2019-02-20 10:18:15 -05:00
|
|
|
context 'with admin_notification_email set' do
|
|
|
|
it 'sends to the admin_notification_email' do
|
|
|
|
is_expected.to deliver_to 'admin@example.com'
|
2016-01-04 18:56:48 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'includes the user in the subject' do
|
2019-02-20 10:18:15 -05:00
|
|
|
is_expected.to have_subject "#{report.user.name} (#{report.user.username}) was reported for abuse"
|
2016-01-04 18:56:48 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'with no admin_notification_email set' do
|
|
|
|
it 'returns early' do
|
|
|
|
stub_application_setting(admin_notification_email: nil)
|
|
|
|
|
2017-06-21 09:48:12 -04:00
|
|
|
expect { described_class.notify(spy).deliver_now }
|
|
|
|
.not_to change { ActionMailer::Base.deliveries.count }
|
2016-01-04 18:56:48 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|