about summary refs log tree commit diff
path: root/spec/mailers
diff options
context:
space:
mode:
authorMatt Jankowski <mjankowski@thoughtbot.com>2017-05-05 14:56:00 -0400
committerGitHub <noreply@github.com>2017-05-05 14:56:00 -0400
commit484c9709b67685c95de351a39e3dfb140acd3681 (patch)
tree0d74cd725e46cd75ca1568d866d5d5ef906b8c0a /spec/mailers
parentd08f1112d517788fb66d2683766cc168bac48315 (diff)
Misc spec coverage improvements (#2821)
* Dont use raise_error by itself (avoids warning)

* Add coverage for AccountFilter

* Improve coverage and refactor for Subscription#lease_seconds

* Improve coverage and refactor for NotificationMailer

* Simplify assignment of min/max threshold on subscription
Diffstat (limited to 'spec/mailers')
-rw-r--r--spec/mailers/notification_mailer_spec.rb30
1 files changed, 30 insertions, 0 deletions
diff --git a/spec/mailers/notification_mailer_spec.rb b/spec/mailers/notification_mailer_spec.rb
index 3beaebeb1..faa3197c8 100644
--- a/spec/mailers/notification_mailer_spec.rb
+++ b/spec/mailers/notification_mailer_spec.rb
@@ -62,4 +62,34 @@ RSpec.describe NotificationMailer, type: :mailer do
     end
   end
 
+  describe 'follow_request' do
+    let(:follow_request) { Fabricate(:follow_request, account: sender, target_account: receiver.account) }
+    let(:mail) { NotificationMailer.follow_request(receiver.account, Notification.create!(account: receiver.account, activity: follow_request)) }
+
+    it 'renders the headers' do
+      expect(mail.subject).to eq('Pending follower: bob')
+      expect(mail.to).to eq([receiver.email])
+    end
+
+    it 'renders the body' do
+      expect(mail.body.encoded).to match("bob has requested to follow you")
+    end
+  end
+
+  describe 'digest' do
+    before do
+      mention = Fabricate(:mention, account: receiver.account)
+      Fabricate(:notification, account: receiver.account, activity: mention)
+    end
+    let(:mail) { NotificationMailer.digest(receiver.account, since: 5.days.ago) }
+
+    it 'renders the headers' do
+      expect(mail.subject).to match('notification since your last')
+      expect(mail.to).to eq([receiver.email])
+    end
+
+    it 'renders the body' do
+      expect(mail.body.encoded).to match('brief summary')
+    end
+  end
 end