about summary refs log tree commit diff
path: root/spec/mailers
diff options
context:
space:
mode:
authorEugen Rochko <eugen@zeonfederated.com>2016-03-19 19:20:07 +0100
committerEugen Rochko <eugen@zeonfederated.com>2016-03-19 19:20:07 +0100
commit2b116131d78460e5cbb8eacc30aaaf04106ea0fa (patch)
tree62ff3751b4f94b36335d5bd7d45374e024cd1d19 /spec/mailers
parente2b846f630cae00096a42dffeff759d0ef8e1c3e (diff)
Adding e-mail notifications about mentions, follows, favourites and reblogs. Fixing another mention recording bug
Diffstat (limited to 'spec/mailers')
-rw-r--r--spec/mailers/notification_mailer_spec.rb61
-rw-r--r--spec/mailers/previews/notification_mailer_preview.rb24
2 files changed, 85 insertions, 0 deletions
diff --git a/spec/mailers/notification_mailer_spec.rb b/spec/mailers/notification_mailer_spec.rb
new file mode 100644
index 000000000..d7a956b75
--- /dev/null
+++ b/spec/mailers/notification_mailer_spec.rb
@@ -0,0 +1,61 @@
+require "rails_helper"
+
+RSpec.describe NotificationMailer, type: :mailer do
+  let(:receiver)       { Fabricate(:user, account: Fabricate(:account, username: 'alice')) }
+  let(:sender)         { Fabricate(:account, username: 'bob') }
+  let(:foreign_status) { Fabricate(:status, account: sender) }
+  let(:own_status)     { Fabricate(:status, account: receiver.account) }
+
+  describe "mention" do
+    let(:mail) { NotificationMailer.mention(receiver.account, foreign_status) }
+
+    it "renders the headers" do
+      expect(mail.subject).to eq("You were mentioned by bob")
+      expect(mail.to).to eq([receiver.email])
+    end
+
+    it "renders the body" do
+      expect(mail.body.encoded).to match("You were mentioned by bob")
+    end
+  end
+
+  describe "follow" do
+    let(:mail) { NotificationMailer.follow(receiver.account, sender) }
+
+    it "renders the headers" do
+      expect(mail.subject).to eq("bob is now following you")
+      expect(mail.to).to eq([receiver.email])
+    end
+
+    it "renders the body" do
+      expect(mail.body.encoded).to match("bob is now following you")
+    end
+  end
+
+  describe "favourite" do
+    let(:mail) { NotificationMailer.favourite(own_status, sender) }
+
+    it "renders the headers" do
+      expect(mail.subject).to eq("bob favourited your status")
+      expect(mail.to).to eq([receiver.email])
+    end
+
+    it "renders the body" do
+      expect(mail.body.encoded).to match("Your status was favourited by bob")
+    end
+  end
+
+  describe "reblog" do
+    let(:mail) { NotificationMailer.reblog(own_status, sender) }
+
+    it "renders the headers" do
+      expect(mail.subject).to eq("bob reblogged your status")
+      expect(mail.to).to eq([receiver.email])
+    end
+
+    it "renders the body" do
+      expect(mail.body.encoded).to match("Your status was reblogged by bob")
+    end
+  end
+
+end
diff --git a/spec/mailers/previews/notification_mailer_preview.rb b/spec/mailers/previews/notification_mailer_preview.rb
new file mode 100644
index 000000000..8fc8d0d34
--- /dev/null
+++ b/spec/mailers/previews/notification_mailer_preview.rb
@@ -0,0 +1,24 @@
+# Preview all emails at http://localhost:3000/rails/mailers/notification_mailer
+class NotificationMailerPreview < ActionMailer::Preview
+
+  # Preview this email at http://localhost:3000/rails/mailers/notification_mailer/mention
+  def mention
+    # NotificationMailer.mention
+  end
+
+  # Preview this email at http://localhost:3000/rails/mailers/notification_mailer/follow
+  def follow
+    # NotificationMailer.follow
+  end
+
+  # Preview this email at http://localhost:3000/rails/mailers/notification_mailer/favourite
+  def favourite
+    # NotificationMailer.favourite
+  end
+
+  # Preview this email at http://localhost:3000/rails/mailers/notification_mailer/reblog
+  def reblog
+    # NotificationMailer.reblog
+  end
+
+end