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.
This commit is contained in:
Javi Martín
2021-11-29 15:55:06 +01:00
parent 51da643f2a
commit 735f99f877
2 changed files with 7 additions and 5 deletions

View File

@@ -1,10 +1,6 @@
module MailerHelper module MailerHelper
def commentable_url(commentable) def commentable_url(commentable)
return poll_url(commentable) if commentable.is_a?(Poll) polymorphic_url(commentable)
return debate_url(commentable) if commentable.is_a?(Debate)
return proposal_url(commentable) if commentable.is_a?(Proposal)
return community_topic_url(commentable.community_id, commentable) if commentable.is_a?(Topic)
return budget_investment_url(commentable.budget_id, commentable) if commentable.is_a?(Budget::Investment)
end end
def valuation_comments_url(commentable) def valuation_comments_url(commentable)

View File

@@ -22,5 +22,11 @@ describe Mailer do
expect(email).to deliver_from "New organization <new@consul.dev>" expect(email).to deliver_from "New organization <new@consul.dev>"
end 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
end end