Files
nairobi/spec/mailers/mailer_spec.rb
taitus 0af765a3bd Update "comment" notification email to add unsubscribe link
We modified the link that previously redirected us to the "My content"
page to redirect us to the new page for managing subscriptions.

We also adapted the existing generic text by adding a description of
the related notification.
2022-01-21 20:21:52 +01:00

55 lines
1.6 KiB
Ruby

require "rails_helper"
describe Mailer do
describe "#comment" do
it "sends emails in the user's locale" do
user = create(:user, locale: "es")
proposal = create(:proposal, author: user)
comment = create(:comment, commentable: proposal)
email = I18n.with_locale :en do
Mailer.comment(comment)
end
expect(email.subject).to include("comentado")
end
it "reads the from address at runtime" do
Setting["mailer_from_name"] = "New organization"
Setting["mailer_from_address"] = "new@consul.dev"
email = Mailer.comment(create(:comment))
expect(email).to deliver_from "New organization <new@consul.dev>"
end
it "sends emails for comments on legislation proposals" do
email = Mailer.comment(create(:legislation_proposal_comment))
expect(email.subject).to include("commented on your proposal")
end
end
describe "#manage_subscriptions_token" do
let(:user) { create(:user) }
let(:proposal) { create(:proposal, author: user) }
let(:comment) { create(:comment, commentable: proposal) }
it "generates a subscriptions token when the receiver doesn't have one" do
user.update!(subscriptions_token: nil)
Mailer.comment(comment).deliver_now
expect(user.reload.subscriptions_token).to be_present
end
it "uses the existing subscriptions token when the receivesr already has one" do
user.update!(subscriptions_token: "subscriptions_token_value")
Mailer.comment(comment).deliver_now
expect(user.subscriptions_token).to eq "subscriptions_token_value"
end
end
end