Files
nairobi/spec/mailers/mailer_spec.rb
Javi Martín 735f99f877 Fix comment notifications on legislation proposals
The `commentable_url` method wasn't updated when we added legislation
proposals.

Back when we first created this method, we couldn't pass budget
investments or topics directly to `polymorphic_url` because they are
nested resources. That isn't the case since commit ff93f5a59, so now we
can simplify this method.

We're keeping the `commentable_url` method for now in order to keep
compatibility with custom changes that might use it, although this
method isn't consistent with the `commentable_path` method (which
receives a comment, and not a commentable), and so we might have to
revisit this code in the future.
2021-11-29 16:16:15 +01:00

33 lines
909 B
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
end