admin_mailer_spec.rb 900 B

12345678910111213141516171819202122
  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', user: Fabricate(:user)) }
  6. let(:recipient) { Fabricate(:account, username: 'Mike', user: Fabricate(:user, locale: :en)) }
  7. let(:report) { Fabricate(:report, account: sender, target_account: recipient) }
  8. let(:mail) { described_class.new_report(recipient, report) }
  9. it 'renders the headers' do
  10. expect(mail.subject).to eq("New report for cb6e6126.ngrok.io (##{report.id})")
  11. expect(mail.to).to eq [recipient.user_email]
  12. expect(mail.from).to eq ['notifications@localhost']
  13. end
  14. it 'renders the body' do
  15. 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")
  16. end
  17. end
  18. end