2018-12-21 09:34:34 +01:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
require 'rails_helper'
|
|
|
|
|
2023-05-04 05:49:53 +02:00
|
|
|
RSpec.describe AdminMailer do
|
2018-12-21 09:34:34 +01:00
|
|
|
describe '.new_report' do
|
2022-01-28 00:46:42 +01:00
|
|
|
let(:sender) { Fabricate(:account, username: 'John') }
|
|
|
|
let(:recipient) { Fabricate(:account, username: 'Mike') }
|
2018-12-21 09:34:34 +01:00
|
|
|
let(:report) { Fabricate(:report, account: sender, target_account: recipient) }
|
2023-07-08 20:03:38 +02:00
|
|
|
let(:mail) { described_class.with(recipient: recipient).new_report(report) }
|
2018-12-21 09:34:34 +01:00
|
|
|
|
2022-01-28 00:46:42 +01:00
|
|
|
before do
|
|
|
|
recipient.user.update(locale: :en)
|
|
|
|
end
|
|
|
|
|
2023-11-17 10:50:19 +01:00
|
|
|
it 'renders the email' do
|
|
|
|
expect(mail)
|
|
|
|
.to be_present
|
|
|
|
.and(deliver_to(recipient.user_email))
|
|
|
|
.and(deliver_from('notifications@localhost'))
|
|
|
|
.and(have_subject("New report for cb6e6126.ngrok.io (##{report.id})"))
|
|
|
|
.and(have_body_text("Mike,\r\n\r\nJohn has reported Mike\r\n\r\nView: https://cb6e6126.ngrok.io/admin/reports/#{report.id}\r\n"))
|
2018-12-21 09:34:34 +01:00
|
|
|
end
|
|
|
|
end
|
2023-02-28 14:33:34 +01:00
|
|
|
|
|
|
|
describe '.new_appeal' do
|
|
|
|
let(:appeal) { Fabricate(:appeal) }
|
|
|
|
let(:recipient) { Fabricate(:account, username: 'Kurt') }
|
2023-07-08 20:03:38 +02:00
|
|
|
let(:mail) { described_class.with(recipient: recipient).new_appeal(appeal) }
|
2023-02-28 14:33:34 +01:00
|
|
|
|
|
|
|
before do
|
|
|
|
recipient.user.update(locale: :en)
|
|
|
|
end
|
|
|
|
|
2023-11-17 10:50:19 +01:00
|
|
|
it 'renders the email' do
|
|
|
|
expect(mail)
|
|
|
|
.to be_present
|
|
|
|
.and(deliver_to(recipient.user_email))
|
|
|
|
.and(deliver_from('notifications@localhost'))
|
|
|
|
.and(have_subject("#{appeal.account.username} is appealing a moderation decision on cb6e6126.ngrok.io"))
|
|
|
|
.and(have_body_text("#{appeal.account.username} is appealing a moderation decision by #{appeal.strike.account.username}"))
|
2023-02-28 14:33:34 +01:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe '.new_pending_account' do
|
|
|
|
let(:recipient) { Fabricate(:account, username: 'Barklums') }
|
|
|
|
let(:user) { Fabricate(:user) }
|
2023-07-08 20:03:38 +02:00
|
|
|
let(:mail) { described_class.with(recipient: recipient).new_pending_account(user) }
|
2023-02-28 14:33:34 +01:00
|
|
|
|
|
|
|
before do
|
|
|
|
recipient.user.update(locale: :en)
|
|
|
|
end
|
|
|
|
|
2023-11-17 10:50:19 +01:00
|
|
|
it 'renders the email' do
|
|
|
|
expect(mail)
|
|
|
|
.to be_present
|
|
|
|
.and(deliver_to(recipient.user_email))
|
|
|
|
.and(deliver_from('notifications@localhost'))
|
|
|
|
.and(have_subject("New account up for review on cb6e6126.ngrok.io (#{user.account.username})"))
|
|
|
|
.and(have_body_text('The details of the new account are below. You can approve or reject this application.'))
|
2023-02-28 14:33:34 +01:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe '.new_trends' do
|
|
|
|
let(:recipient) { Fabricate(:account, username: 'Snurf') }
|
2023-11-21 11:52:20 +01:00
|
|
|
let(:link) { Fabricate(:preview_card, trendable: true, language: 'en') }
|
|
|
|
let(:status) { Fabricate(:status) }
|
|
|
|
let(:tag) { Fabricate(:tag) }
|
|
|
|
let(:mail) { described_class.with(recipient: recipient).new_trends([link], [tag], [status]) }
|
2023-02-28 14:33:34 +01:00
|
|
|
|
|
|
|
before do
|
2023-11-21 11:52:20 +01:00
|
|
|
PreviewCardTrend.create!(preview_card: link)
|
|
|
|
StatusTrend.create!(status: status, account: Fabricate(:account))
|
2023-02-28 14:33:34 +01:00
|
|
|
recipient.user.update(locale: :en)
|
|
|
|
end
|
|
|
|
|
2023-11-17 10:50:19 +01:00
|
|
|
it 'renders the email' do
|
|
|
|
expect(mail)
|
|
|
|
.to be_present
|
|
|
|
.and(deliver_to(recipient.user_email))
|
|
|
|
.and(deliver_from('notifications@localhost'))
|
|
|
|
.and(have_subject('New trends up for review on cb6e6126.ngrok.io'))
|
|
|
|
.and(have_body_text('The following items need a review before they can be displayed publicly'))
|
2023-11-21 11:52:20 +01:00
|
|
|
.and(have_body_text(ActivityPub::TagManager.instance.url_for(status)))
|
|
|
|
.and(have_body_text(link.title))
|
|
|
|
.and(have_body_text(tag.display_name))
|
2023-02-28 14:33:34 +01:00
|
|
|
end
|
|
|
|
end
|
2023-09-01 17:47:07 +02:00
|
|
|
|
|
|
|
describe '.new_software_updates' do
|
|
|
|
let(:recipient) { Fabricate(:account, username: 'Bob') }
|
|
|
|
let(:mail) { described_class.with(recipient: recipient).new_software_updates }
|
|
|
|
|
|
|
|
before do
|
|
|
|
recipient.user.update(locale: :en)
|
|
|
|
end
|
|
|
|
|
2023-11-17 10:50:19 +01:00
|
|
|
it 'renders the email' do
|
|
|
|
expect(mail)
|
|
|
|
.to be_present
|
|
|
|
.and(deliver_to(recipient.user_email))
|
|
|
|
.and(deliver_from('notifications@localhost'))
|
|
|
|
.and(have_subject('New Mastodon versions are available for cb6e6126.ngrok.io!'))
|
|
|
|
.and(have_body_text('New Mastodon versions have been released, you may want to update!'))
|
2023-09-01 17:47:07 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe '.new_critical_software_updates' do
|
|
|
|
let(:recipient) { Fabricate(:account, username: 'Bob') }
|
|
|
|
let(:mail) { described_class.with(recipient: recipient).new_critical_software_updates }
|
|
|
|
|
|
|
|
before do
|
|
|
|
recipient.user.update(locale: :en)
|
|
|
|
end
|
|
|
|
|
2023-11-17 10:50:19 +01:00
|
|
|
it 'renders the email' do
|
|
|
|
expect(mail)
|
|
|
|
.to be_present
|
|
|
|
.and(deliver_to(recipient.user_email))
|
|
|
|
.and(deliver_from('notifications@localhost'))
|
|
|
|
.and(have_subject('Critical Mastodon updates are available for cb6e6126.ngrok.io!'))
|
|
|
|
.and(have_body_text('New critical versions of Mastodon have been released, you may want to update as soon as possible!'))
|
|
|
|
.and(have_header('Importance', 'high'))
|
|
|
|
.and(have_header('Priority', 'urgent'))
|
|
|
|
.and(have_header('X-Priority', '1'))
|
2023-09-01 17:47:07 +02:00
|
|
|
end
|
|
|
|
end
|
2018-12-21 09:34:34 +01:00
|
|
|
end
|