about summary refs log tree commit diff
path: root/spec
diff options
context:
space:
mode:
authorMatt Jankowski <matt@jankowski.online>2023-02-28 08:33:34 -0500
committerGitHub <noreply@github.com>2023-02-28 22:33:34 +0900
commit6185efbc3cb87541ee872d67c26911b3b03915e3 (patch)
treed3ea027c8d177a3b9176e91c36b7b6d838e17eba /spec
parentf8848a5c8bfb17fb419c11b3c060c6a4d023addc (diff)
Admin mailer spec coverage improvement (#23863)
Diffstat (limited to 'spec')
-rw-r--r--spec/mailers/admin_mailer_spec.rb62
1 files changed, 62 insertions, 0 deletions
diff --git a/spec/mailers/admin_mailer_spec.rb b/spec/mailers/admin_mailer_spec.rb
index 29fb586a3..132c6c758 100644
--- a/spec/mailers/admin_mailer_spec.rb
+++ b/spec/mailers/admin_mailer_spec.rb
@@ -23,4 +23,66 @@ RSpec.describe AdminMailer, type: :mailer 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
+
+  describe '.new_appeal' do
+    let(:appeal) { Fabricate(:appeal) }
+    let(:recipient) { Fabricate(:account, username: 'Kurt') }
+    let(:mail)      { described_class.new_appeal(recipient, appeal) }
+
+    before do
+      recipient.user.update(locale: :en)
+    end
+
+    it 'renders the headers' do
+      expect(mail.subject).to eq("#{appeal.account.username} is appealing a moderation decision on cb6e6126.ngrok.io")
+      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 match "#{appeal.account.username} is appealing a moderation decision by #{appeal.strike.account.username}"
+    end
+  end
+
+  describe '.new_pending_account' do
+    let(:recipient) { Fabricate(:account, username: 'Barklums') }
+    let(:user) { Fabricate(:user) }
+    let(:mail) { described_class.new_pending_account(recipient, user) }
+
+    before do
+      recipient.user.update(locale: :en)
+    end
+
+    it 'renders the headers' do
+      expect(mail.subject).to eq("New account up for review on cb6e6126.ngrok.io (#{user.account.username})")
+      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 match 'The details of the new account are below. You can approve or reject this application.'
+    end
+  end
+
+  describe '.new_trends' do
+    let(:recipient) { Fabricate(:account, username: 'Snurf') }
+    let(:links) { [] }
+    let(:statuses) { [] }
+    let(:tags) { [] }
+    let(:mail) { described_class.new_trends(recipient, links, tags, statuses) }
+
+    before do
+      recipient.user.update(locale: :en)
+    end
+
+    it 'renders the headers' do
+      expect(mail.subject).to eq('New trends up for review on cb6e6126.ngrok.io')
+      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 match 'The following items need a review before they can be displayed publicly'
+    end
+  end
 end