debian-mirror-gitlab/spec/mailers/abuse_report_mailer_spec.rb

40 lines
1.1 KiB
Ruby
Raw Normal View History

2019-12-26 22:10:19 +05:30
# frozen_string_literal: true
2019-12-04 20:38:33 +05:30
require 'spec_helper'
2020-07-28 23:09:34 +05:30
RSpec.describe AbuseReportMailer do
include EmailSpec::Matchers
describe '.notify' do
2019-07-07 11:18:12 +05:30
before do
2021-01-03 14:25:43 +05:30
stub_application_setting(abuse_notification_email: 'admin@example.com')
2019-07-07 11:18:12 +05:30
end
2019-05-18 00:54:41 +05:30
2019-07-07 11:18:12 +05:30
let(:report) { create(:abuse_report) }
subject { described_class.notify(report.id) }
2019-07-07 11:18:12 +05:30
it_behaves_like 'appearance header and footer enabled'
it_behaves_like 'appearance header and footer not enabled'
2021-01-03 14:25:43 +05:30
context 'with abuse_notification_email set' do
it 'sends to the abuse_notification_email' do
2019-07-07 11:18:12 +05:30
is_expected.to deliver_to 'admin@example.com'
end
it 'includes the user in the subject' do
2019-07-07 11:18:12 +05:30
is_expected.to have_subject "#{report.user.name} (#{report.user.username}) was reported for abuse"
end
end
2021-01-03 14:25:43 +05:30
context 'with no abuse_notification_email set' do
it 'returns early' do
2021-01-03 14:25:43 +05:30
stub_application_setting(abuse_notification_email: nil)
2017-09-10 17:25:29 +05:30
expect { described_class.notify(spy).deliver_now }
.not_to change { ActionMailer::Base.deliveries.count }
end
end
end
end