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.

61 lines
1.8 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(:mail) { NotificationMailer.mention(receiver.account, foreign_status) }
  9. it "renders the headers" do
  10. expect(mail.subject).to eq("You were mentioned by bob")
  11. expect(mail.to).to eq([receiver.email])
  12. end
  13. it "renders the body" do
  14. expect(mail.body.encoded).to match("You were mentioned by bob")
  15. end
  16. end
  17. describe "follow" do
  18. let(:mail) { NotificationMailer.follow(receiver.account, sender) }
  19. it "renders the headers" do
  20. expect(mail.subject).to eq("bob is now following you")
  21. expect(mail.to).to eq([receiver.email])
  22. end
  23. it "renders the body" do
  24. expect(mail.body.encoded).to match("bob is now following you")
  25. end
  26. end
  27. describe "favourite" do
  28. let(:mail) { NotificationMailer.favourite(own_status, sender) }
  29. it "renders the headers" do
  30. expect(mail.subject).to eq("bob favourited your status")
  31. expect(mail.to).to eq([receiver.email])
  32. end
  33. it "renders the body" do
  34. expect(mail.body.encoded).to match("Your status was favourited by bob")
  35. end
  36. end
  37. describe "reblog" do
  38. let(:mail) { NotificationMailer.reblog(own_status, sender) }
  39. it "renders the headers" do
  40. expect(mail.subject).to eq("bob reblogged your status")
  41. expect(mail.to).to eq([receiver.email])
  42. end
  43. it "renders the body" do
  44. expect(mail.body.encoded).to match("Your status was reblogged by bob")
  45. end
  46. end
  47. end