admin_mailer_spec.rb 903 B

1234567891011121314151617181920212223242526
  1. # frozen_string_literal: true
  2. require 'rails_helper'
  3. RSpec.describe AdminMailer, type: :mailer do
  4. describe '.new_report' do
  5. let(:sender) { Fabricate(:account, username: 'John') }
  6. let(:recipient) { Fabricate(:account, username: 'Mike') }
  7. let(:report) { Fabricate(:report, account: sender, target_account: recipient) }
  8. let(:mail) { described_class.new_report(recipient, report) }
  9. before do
  10. recipient.user.update(locale: :en)
  11. end
  12. it 'renders the headers' do
  13. expect(mail.subject).to eq("New report for cb6e6126.ngrok.io (##{report.id})")
  14. expect(mail.to).to eq [recipient.user_email]
  15. expect(mail.from).to eq ['notifications@localhost']
  16. end
  17. it 'renders the body' do
  18. expect(mail.body.encoded).to eq("Mike,\r\n\r\nJohn has reported Mike\r\n\r\nView: https://cb6e6126.ngrok.io/admin/reports/#{report.id}\r\n")
  19. end
  20. end
  21. end