From aa6b590b3c5bdd2cf2af7e301279975519778a7e Mon Sep 17 00:00:00 2001 From: Marcelo Briones Date: Thu, 2 Apr 2015 19:07:49 -0300 Subject: [PATCH] Limited post content excluded from subject of comment email --- .../notification_mailers/comment_on_post.rb | 6 +++++- config/locales/diaspora/en.yml | 1 + spec/mailers/notifier_spec.rb | 20 +++++++++++++++++++ 3 files changed, 26 insertions(+), 1 deletion(-) diff --git a/app/mailers/notification_mailers/comment_on_post.rb b/app/mailers/notification_mailers/comment_on_post.rb index de01804bb..1ad0a5f0f 100644 --- a/app/mailers/notification_mailers/comment_on_post.rb +++ b/app/mailers/notification_mailers/comment_on_post.rb @@ -6,7 +6,11 @@ module NotificationMailers @comment = Comment.find(comment_id) @headers[:from] = "\"#{@comment.author_name} (diaspora*)\" <#{AppConfig.mail.sender_address}>" - @headers[:subject] = "Re: #{@comment.comment_email_subject}" + if @comment.public? + @headers[:subject] = "Re: #{@comment.comment_email_subject}" + else + @headers[:subject] = I18n.t("notifier.comment_on_post.limited_subject") + end end end end diff --git a/config/locales/diaspora/en.yml b/config/locales/diaspora/en.yml index a0d4635ea..981bf84fe 100644 --- a/config/locales/diaspora/en.yml +++ b/config/locales/diaspora/en.yml @@ -742,6 +742,7 @@ en: sharing: "has started sharing with you!" view_profile: "View %{name}’s profile" comment_on_post: + limited_subject: "There's a new comment on a post you commented" reply: "Reply or view %{name}’s post >" mentioned: subject: "%{name} has mentioned you on diaspora*" diff --git a/spec/mailers/notifier_spec.rb b/spec/mailers/notifier_spec.rb index ce99f6a15..c9a0ad9d5 100644 --- a/spec/mailers/notifier_spec.rb +++ b/spec/mailers/notifier_spec.rb @@ -318,6 +318,26 @@ describe Notifier, :type => :mailer do end end + context "limited comments" do + let(:commented_limited_post) { + bob.post(:status_message, to: :all, public: false, + text: "### Limited headline \r\n It's **really** sunny outside today") + } + let(:limited_comment) { eve.comment!(commented_limited_post, "Totally is") } + + describe ".comment_on_limited_post" do + let(:limited_comment_mail) { Notifier.comment_on_post(bob.id, person.id, limited_comment.id).deliver_now } + + it "SUBJECT: does not show limited message" do + expect(limited_comment_mail.subject).not_to include("Limited headline") + end + + it "BODY: does not show limited message" do + expect(limited_comment_mail.body.encoded).not_to include("Limited headline") + end + end + end + describe 'hashtags' do it 'escapes hashtags' do mails = Notifier.admin("#Welcome to bureaucracy!", [bob])