mirror of
https://github.com/funamitech/mastodon
synced 2024-12-05 10:18:45 +09:00
e38fc319dc
* Change account and user fabricators to simplify and improve tests - `Fabricate(:account)` implicitly fabricates an associated `user` if no `domain` attribute is given (an account with `domain: nil` is considered a local account, but no user record was created), unless `user: nil` is passed - `Fabricate(:account, user: Fabricate(:user))` should still be possible but is discouraged. * Fix and refactor tests - avoid passing unneeded attributes to `Fabricate(:user)` or `Fabricate(:account)` - avoid embedding `Fabricate(:user)` into a `Fabricate(:account)` or the other way around - prefer `Fabricate(:user, account_attributes: …)` to `Fabricate(:user, account: Fabricate(:account, …)` - also, some tests were using remote accounts with local user records, which is not representative of production code.
27 lines
903 B
Ruby
27 lines
903 B
Ruby
# frozen_string_literal: true
|
|
|
|
require 'rails_helper'
|
|
|
|
RSpec.describe AdminMailer, type: :mailer do
|
|
describe '.new_report' do
|
|
let(:sender) { Fabricate(:account, username: 'John') }
|
|
let(:recipient) { Fabricate(:account, username: 'Mike') }
|
|
let(:report) { Fabricate(:report, account: sender, target_account: recipient) }
|
|
let(:mail) { described_class.new_report(recipient, report) }
|
|
|
|
before do
|
|
recipient.user.update(locale: :en)
|
|
end
|
|
|
|
it 'renders the headers' do
|
|
expect(mail.subject).to eq("New report for cb6e6126.ngrok.io (##{report.id})")
|
|
expect(mail.to).to eq [recipient.user_email]
|
|
expect(mail.from).to eq ['notifications@localhost']
|
|
end
|
|
|
|
it 'renders the body' do
|
|
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")
|
|
end
|
|
end
|
|
end
|