fixed the 'a post' bug in notification emails
This commit is contained in:
parent
55daaf2b6c
commit
08f12ee348
6 changed files with 38 additions and 4 deletions
|
|
@ -1,4 +1,8 @@
|
||||||
module NotifierHelper
|
module NotifierHelper
|
||||||
|
|
||||||
|
# @param post [Post] The post object.
|
||||||
|
# @param opts [Hash] Optional hash. Accepts :length and :process_newlines parameters.
|
||||||
|
# @return [String] The truncated and formatted post.
|
||||||
def post_message(post, opts={})
|
def post_message(post, opts={})
|
||||||
opts[:length] ||= 200
|
opts[:length] ||= 200
|
||||||
if post.respond_to? :formatted_message
|
if post.respond_to? :formatted_message
|
||||||
|
|
@ -9,4 +13,14 @@ module NotifierHelper
|
||||||
I18n.translate 'notifier.a_post_you_shared'
|
I18n.translate 'notifier.a_post_you_shared'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# @param comment [Comment] The comment to process.
|
||||||
|
# @param opts [Hash] Optional hash. Accepts :length and :process_newlines parameters.
|
||||||
|
# @return [String] The truncated and formatted comment.
|
||||||
|
def comment_message(comment, opts={})
|
||||||
|
opts[:length] ||= 600
|
||||||
|
text = truncate(@comment.text, :length => opts[:length])
|
||||||
|
text = process_newlines(text) if opts[:process_newlines]
|
||||||
|
text
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
%p
|
%p
|
||||||
= post_message(@comment, :process_newlines => true, :length => 600)
|
= comment_message(@comment.text, :process_newlines => true)
|
||||||
%p
|
%p
|
||||||
= link_to t('notifier.comment_on_post.reply', :name => @comment.post.author.first_name), post_url(@comment.post)
|
= link_to t('notifier.comment_on_post.reply', :name => @comment.post.author.first_name), post_url(@comment.post)
|
||||||
|
|
|
||||||
|
|
@ -1 +1 @@
|
||||||
!= truncate(@comment.text, :length => 600)
|
!= comment_message(@comment.text)
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
%p
|
%p
|
||||||
= post_message(@comment, :process_newlines => true, :length => 600)
|
= comment_message(@comment.text, :process_newlines => true)
|
||||||
%p
|
%p
|
||||||
= link_to t('notifier.comment_on_post.reply', :name => @comment.post.author.name), post_url(@comment.post)
|
= link_to t('notifier.comment_on_post.reply', :name => @comment.post.author.name), post_url(@comment.post)
|
||||||
|
|
|
||||||
|
|
@ -1 +1 @@
|
||||||
!= truncate(@comment.text, :length => 600)
|
!= comment_message(@comment.text)
|
||||||
|
|
|
||||||
20
spec/helpers/notifier_helper_spec.rb
Normal file
20
spec/helpers/notifier_helper_spec.rb
Normal file
|
|
@ -0,0 +1,20 @@
|
||||||
|
# Copyright (c) 2011, Diaspora Inc. This file is
|
||||||
|
# licensed under the Affero General Public License version 3 or later. See
|
||||||
|
# the COPYRIGHT file.
|
||||||
|
|
||||||
|
require 'spec_helper'
|
||||||
|
|
||||||
|
describe NotifierHelper do
|
||||||
|
include MarkdownifyHelper
|
||||||
|
|
||||||
|
describe '#comment_message' do
|
||||||
|
before do
|
||||||
|
@comment = Factory(:comment)
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'truncates the comment' do
|
||||||
|
opts = {:length => 2}
|
||||||
|
comment_message(@comment, opts).should == truncate(@comment.text, opts)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
Loading…
Reference in a new issue