You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

65 lines
2.3 KiB

  1. require "rails_helper"
  2. RSpec.describe NotificationMailer, type: :mailer do
  3. let(:receiver) { Fabricate(:user, account: Fabricate(:account, username: 'alice')) }
  4. let(:sender) { Fabricate(:account, username: 'bob') }
  5. let(:foreign_status) { Fabricate(:status, account: sender) }
  6. let(:own_status) { Fabricate(:status, account: receiver.account) }
  7. describe "mention" do
  8. let(:mention) { Mention.create!(account: receiver.account, status: foreign_status) }
  9. let(:mail) { NotificationMailer.mention(receiver.account, Notification.create!(account: receiver.account, activity: mention)) }
  10. it "renders the headers" do
  11. expect(mail.subject).to eq("You were mentioned by bob")
  12. expect(mail.to).to eq([receiver.email])
  13. end
  14. it "renders the body" do
  15. expect(mail.body.encoded).to match("You were mentioned by bob")
  16. end
  17. end
  18. describe "follow" do
  19. let(:follow) { sender.follow!(receiver.account) }
  20. let(:mail) { NotificationMailer.follow(receiver.account, Notification.create!(account: receiver.account, activity: follow)) }
  21. it "renders the headers" do
  22. expect(mail.subject).to eq("bob is now following you")
  23. expect(mail.to).to eq([receiver.email])
  24. end
  25. it "renders the body" do
  26. expect(mail.body.encoded).to match("bob is now following you")
  27. end
  28. end
  29. describe "favourite" do
  30. let(:favourite) { Favourite.create!(account: sender, status: own_status) }
  31. let(:mail) { NotificationMailer.favourite(own_status.account, Notification.create!(account: receiver.account, activity: favourite)) }
  32. it "renders the headers" do
  33. expect(mail.subject).to eq("bob favourited your status")
  34. expect(mail.to).to eq([receiver.email])
  35. end
  36. it "renders the body" do
  37. expect(mail.body.encoded).to match("Your status was favourited by bob")
  38. end
  39. end
  40. describe "reblog" do
  41. let(:reblog) { Status.create!(account: sender, reblog: own_status) }
  42. let(:mail) { NotificationMailer.reblog(own_status.account, Notification.create!(account: receiver.account, activity: reblog)) }
  43. it "renders the headers" do
  44. expect(mail.subject).to eq("bob reblogged your status")
  45. expect(mail.to).to eq([receiver.email])
  46. end
  47. it "renders the body" do
  48. expect(mail.body.encoded).to match("Your status was reblogged by bob")
  49. end
  50. end
  51. end