From 8086b9a9d4afa789b308ad3b4c0fe7434842b15a Mon Sep 17 00:00:00 2001 From: Raphael Sofaer Date: Wed, 10 Aug 2011 16:58:35 -0700 Subject: [PATCH] Eliminate 500 errors on also_commented emails, the copy there is terrible --- app/mailers/notifier.rb | 3 ++- spec/mailers/notifier_spec.rb | 12 +++++++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/app/mailers/notifier.rb b/app/mailers/notifier.rb index 07717ac37..35249586e 100644 --- a/app/mailers/notifier.rb +++ b/app/mailers/notifier.rb @@ -89,9 +89,10 @@ class Notifier < ActionMailer::Base log_mail(recipient_id, sender_id, 'comment_on_post') I18n.with_locale(@receiver.language) do + subject_message = post_message(@comment.parent, :length => TRUNCATION_LEN) mail(:from => "\"#{@sender.name} (Diaspora)\" <#{AppConfig[:smtp_sender_address]}>", :to => "\"#{@receiver.name}\" <#{@receiver.email}>", - :subject => "Re: #{truncate(@comment.parent.formatted_message(:plain_text => true).strip, :length => TRUNCATION_LEN)}") + :subject => "Re: #{subject_message}") end end diff --git a/spec/mailers/notifier_spec.rb b/spec/mailers/notifier_spec.rb index 594576d71..5640c4963 100644 --- a/spec/mailers/notifier_spec.rb +++ b/spec/mailers/notifier_spec.rb @@ -215,7 +215,7 @@ describe Notifier do end describe ".also_commented" do - let!(:comment_mail) {Notifier.also_commented(user.id, person.id, comment.id)} + let(:comment_mail) {Notifier.also_commented(user.id, person.id, comment.id)} it 'TO: goes to the right person' do comment_mail.to.should == [user.email] @@ -239,6 +239,16 @@ describe Notifier do comment_mail.body.encoded.include?("#{comment.post.id.to_s}").should be true end end + [:reshare, :activity_streams_photo].each do |post_type| + context post_type.to_s do + let(:commented_post) { Factory(post_type, :author => user.person) } + it 'succeeds' do + proc { + comment_mail + }.should_not raise_error + end + end + end end describe ".confirm_email" do