Commit 1bea16bd09961fd32e68557dceacb8d56beddbf2

Authored by Antonio Terceiro
1 parent ec7def9f

Include comment title and body in notifications

(ActionItem1609)
app/models/comment.rb
@@ -81,6 +81,8 @@ class Comment < ActiveRecord::Base @@ -81,6 +81,8 @@ class Comment < ActiveRecord::Base
81 :sender_link => comment.author_link, 81 :sender_link => comment.author_link,
82 :article_title => comment.article.name, 82 :article_title => comment.article.name,
83 :comment_url => comment.url, 83 :comment_url => comment.url,
  84 + :comment_title => comment.title,
  85 + :comment_body => comment.body,
84 :environment => profile.environment.name, 86 :environment => profile.environment.name,
85 :url => profile.environment.top_url 87 :url => profile.environment.top_url
86 end 88 end
app/views/comment/notifier/mail.rhtml
@@ -2,9 +2,18 @@ @@ -2,9 +2,18 @@
2 2
3 <%= word_wrap(_('%{sender} (%{sender_link}) created a new comment on your article "%{article_title}".') % { :sender => @sender, :sender_link => url_for(@sender_link), :article_title => @article_title }) %> 3 <%= word_wrap(_('%{sender} (%{sender_link}) created a new comment on your article "%{article_title}".') % { :sender => @sender, :sender_link => url_for(@sender_link), :article_title => @article_title }) %>
4 4
  5 +<%= word_wrap(_('Title: %s') % @comment_title) %>
  6 +
  7 +<%= _("Comment:") %>
  8 +-------------------------------------------------------------------------------
  9 +<%= word_wrap(@comment_body) %>
  10 +-------------------------------------------------------------------------------
  11 +
5 <%= _('Access the address below to view this comment:') %> 12 <%= _('Access the address below to view this comment:') %>
6 <%= url_for @comment_url %> 13 <%= url_for @comment_url %>
7 14
  15 +<%= _("Greetings,") %>
  16 +
8 -- 17 --
9 -<%= _('%s environment system') % @environment %> 18 +<%= _('%s team.') % @environment %>
10 <%= url_for @url %> 19 <%= url_for @url %>
test/unit/comment_notifier_test.rb
@@ -44,6 +44,18 @@ class CommentNotifierTest &lt; Test::Unit::TestCase @@ -44,6 +44,18 @@ class CommentNotifierTest &lt; Test::Unit::TestCase
44 end 44 end
45 end 45 end
46 46
  47 + should 'include comment title in the e-mail' do
  48 + @article.comments << Comment.new(:author => @profile, :title => 'comment title', :body => 'comment title')
  49 + sent = ActionMailer::Base.deliveries.first
  50 + assert_match /comment title/, sent.body
  51 + end
  52 +
  53 + should 'include comment text in the e-mail' do
  54 + @article.comments << Comment.new(:author => @profile, :title => 'comment title', :body => 'comment body')
  55 + sent = ActionMailer::Base.deliveries.first
  56 + assert_match /comment body/, sent.body
  57 + end
  58 +
47 private 59 private
48 60
49 def read_fixture(action) 61 def read_fixture(action)