Add unsubscribe link to diary comment notification email
This commit is contained in:
parent
3a873b1668
commit
a07df4c67b
5 changed files with 23 additions and 0 deletions
|
@ -97,6 +97,7 @@ class UserMailer < ApplicationMailer
|
|||
@readurl = diary_entry_url(comment.diary_entry.user, comment.diary_entry, :anchor => "comment#{comment.id}")
|
||||
@commenturl = diary_entry_url(comment.diary_entry.user, comment.diary_entry, :anchor => "newcomment")
|
||||
@replyurl = new_message_url(comment.user, :message => { :title => "Re: #{comment.diary_entry.title}" })
|
||||
@unsubscribeurl = diary_entry_unsubscribe_url(comment.diary_entry.user, comment.diary_entry)
|
||||
@author = @from_user
|
||||
|
||||
attach_user_avatar(comment.user)
|
||||
|
|
|
@ -15,4 +15,7 @@
|
|||
:commenturl => link_to(@commenturl, @commenturl) + tag.br,
|
||||
:replyurl => link_to(@replyurl, @replyurl) %>
|
||||
</p>
|
||||
<p><%= t ".footer_unsubscribe_html",
|
||||
:unsubscribeurl => link_to(@unsubscribeurl, @unsubscribeurl) %>
|
||||
</p>
|
||||
<% end %>
|
||||
|
|
|
@ -7,3 +7,5 @@
|
|||
==
|
||||
|
||||
<%= t '.footer', :readurl => @readurl, :commenturl => @commenturl, :replyurl => @replyurl %>
|
||||
|
||||
<%= t '.footer_unsubscribe', :unsubscribeurl => @unsubscribeurl %>
|
||||
|
|
|
@ -1577,6 +1577,8 @@ en:
|
|||
header_html: "%{from_user} has commented on the OpenStreetMap diary entry with the subject %{subject}:"
|
||||
footer: "You can also read the comment at %{readurl} and you can comment at %{commenturl} or send a message to the author at %{replyurl}"
|
||||
footer_html: "You can also read the comment at %{readurl} and you can comment at %{commenturl} or send a message to the author at %{replyurl}"
|
||||
footer_unsubscribe: "You can unsubscribe from the discussion at %{unsubscribeurl}"
|
||||
footer_unsubscribe_html: "You can unsubscribe from the discussion at %{unsubscribeurl}"
|
||||
message_notification:
|
||||
subject: "[OpenStreetMap] %{message_title}"
|
||||
hi: "Hi %{to_user},"
|
||||
|
|
|
@ -53,4 +53,19 @@ class UserMailerTest < ActionMailer::TestCase
|
|||
assert_match("Jack & Jill <br>", email.text_part.body.to_s)
|
||||
assert_match("Jack & Jill <br>", email.html_part.body.to_s)
|
||||
end
|
||||
|
||||
def test_diary_comment_notification
|
||||
create(:language, :code => "en")
|
||||
user = create(:user)
|
||||
other_user = create(:user)
|
||||
diary_entry = create(:diary_entry, :user => user)
|
||||
diary_comment = create(:diary_comment, :diary_entry => diary_entry)
|
||||
email = UserMailer.diary_comment_notification(diary_comment, other_user)
|
||||
body = Rails::Dom::Testing.html_document_fragment.parse(email.html_part.body)
|
||||
|
||||
url = Rails.application.routes.url_helpers.diary_entry_url(user, diary_entry, :host => Settings.server_url, :protocol => Settings.server_protocol)
|
||||
unsubscribe_url = Rails.application.routes.url_helpers.diary_entry_unsubscribe_url(user, diary_entry, :host => Settings.server_url, :protocol => Settings.server_protocol)
|
||||
assert_select body, "a[href^='#{url}']"
|
||||
assert_select body, "a[href='#{unsubscribe_url}']", :count => 1
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue