diff options
author | danielgrippi <danielgrippi@gmail.com> | 2011-07-16 08:22:07 +0400 |
---|---|---|
committer | danielgrippi <danielgrippi@gmail.com> | 2011-07-16 08:22:29 +0400 |
commit | c4b715f3ff1b2162b70f0df4d43dfc7fa1552ecc (patch) | |
tree | 04b152150e4d58b659b8e401eb632b23c6d7baaf /spec | |
parent | 8cfd2e02e165201996d1a6831d9ec6eeb13f0da7 (diff) |
fixed emails to show avatars, have subject lines that allow threading in email clients, and relevant content previews
Diffstat (limited to 'spec')
-rw-r--r-- | spec/mailers/notifier_spec.rb | 106 |
1 files changed, 58 insertions, 48 deletions
diff --git a/spec/mailers/notifier_spec.rb b/spec/mailers/notifier_spec.rb index 1eeb068ab..f585b7841 100644 --- a/spec/mailers/notifier_spec.rb +++ b/spec/mailers/notifier_spec.rb @@ -1,7 +1,8 @@ - require 'spec_helper' describe Notifier do + include ActionView::Helpers::TextHelper + let!(:user) {alice} let!(:user2) {eve} @@ -47,7 +48,7 @@ describe Notifier do it 'has the layout' do mail = Notifier.single_admin("Welcome to bureaucracy!", user) - mail.body.encoded.should match /manage your email settings/ + mail.body.encoded.should match /change your notification settings/ end end @@ -57,10 +58,6 @@ describe Notifier do request_mail.to.should == [user.email] end - it 'has the receivers name in the body' do - request_mail.body.encoded.include?(user.person.profile.first_name).should be true - end - it 'has the name of person sending the request' do request_mail.body.encoded.include?(person.name).should be true end @@ -73,21 +70,18 @@ describe Notifier do describe ".mentioned" do before do @user = alice - @sm = Factory(:status_message) - @m = Mention.create(:person => @user.person, :post=> @sm) + @sm = Factory(:status_message) + @m = Mention.create(:person => @user.person, :post=> @sm) @mail = Notifier.mentioned(@user.id, @sm.author.id, @m.id) end - it 'goes to the right person' do - @mail.to.should == [@user.email] - end - it 'has the receivers name in the body' do - @mail.body.encoded.include?(@user.person.profile.first_name).should be_true + it 'TO: goes to the right person' do + @mail.to.should == [@user.email] end - it 'has the name of person mentioning in the body' do - @mail.body.encoded.include?(@sm.author.name).should be_true + it 'SUBJECT: has the name of person mentioning in the subject' do + @mail.subject.should include(@sm.author.name) end it 'has the post text in the body' do @@ -106,16 +100,16 @@ describe Notifier do @mail = Notifier.liked(alice.id, @like.author.id, @like.id) end - it 'goes to the right person' do + it 'TO: goes to the right person' do @mail.to.should == [alice.email] end - it 'has the receivers name in the body' do - @mail.body.encoded.include?(alice.person.profile.first_name).should be true + it 'BODY: contains the truncated original post' do + @mail.body.encoded.should include(@sm.formatted_message) end - it 'has the name of person liking in the body' do - @mail.body.encoded.include?(@like.author.name).should be_true + it 'BODY: contains the name of person liking' do + @mail.body.encoded.should include(@like.author.name) end it 'should not include translation missing' do @@ -135,23 +129,28 @@ describe Notifier do @mail = Notifier.private_message(user.id, @cnv.author.id, @cnv.messages.first.id) end - it 'goes to the right person' do + + it 'TO: goes to the right person' do @mail.to.should == [user.email] end - it 'has the recipients in the body' do - @mail.body.encoded.include?(user.person.first_name).should be true + it "FROM: contains the sender's name" do + pending + @mail.from.should == "\"#{person.name} (Diaspora)\" <#{AppConfig[:smtp_sender_address]}>" end - it 'has the name of the sender in the body' do - @mail.body.encoded.include?(@cnv.author.name).should be true + it 'SUBJECT: has a snippet of the post contents' do + @mail.subject.should == @cnv.subject end - it 'has the conversation subject in the body' do - @mail.body.encoded.should include(@cnv.subject) + it 'SUBJECT: has "Re:" if not the first message in a conversation' do + @cnv.messages << Message.new(:text => 'yo', :author => eve.person) + @mail = Notifier.private_message(user.id, @cnv.author.id, @cnv.messages.last.id) + + @mail.subject.should == "Re: #{@cnv.subject}" end - it 'has the post text in the body' do + it 'BODY: contains the message text' do @mail.body.encoded.should include(@cnv.messages.first.text) end @@ -162,50 +161,61 @@ describe Notifier do context "comments" do let!(:connect) { connect_users(user, aspect, user2, aspect2)} - let!(:sm) {user.post(:status_message, :text => "Sunny outside", :to => :all)} + let!(:sm) {user.post(:status_message, :text => "It's really sunny outside today, and this is a super long status message! #notreally", :to => :all)} let!(:comment) { user2.comment("Totally is", :post => sm )} - describe ".comment_on_post" do + describe ".comment_on_post" do let!(:comment_mail) {Notifier.comment_on_post(user.id, person.id, comment.id).deliver} - it 'goes to the right person' do + it 'TO: goes to the right person' do comment_mail.to.should == [user.email] end - it 'has the receivers name in the body' do - comment_mail.body.encoded.include?(user.person.profile.first_name).should be true + it "FROM: contains the sender's name" do + pending + comment_mail.from.should == "\"#{person.name} (Diaspora)\" <#{AppConfig[:smtp_sender_address]}>" end - it 'has the name of person commenting' do - comment_mail.body.encoded.include?(person.name).should be true + it 'SUBJECT: has a snippet of the post contents' do + comment_mail.subject.should == "Re: #{truncate(sm.text, :length => 70)}" end - it 'has the post link in the body' do - comment_mail.body.encoded.include?("#{comment.post.id.to_s}").should be true - end + context 'BODY' do + it "contains the comment" do + comment_mail.body.encoded.should include(comment.text) + end + it "contains the original post's link" do + comment_mail.body.encoded.include?("#{comment.post.id.to_s}").should be true + end + end end - describe ".also commented" do + describe ".also_commented" do let!(:comment_mail) {Notifier.also_commented(user.id, person.id, comment.id)} - it 'goes to the right person' do + it 'TO: goes to the right person' do comment_mail.to.should == [user.email] end - it 'has the receivers name in the body' do - comment_mail.body.encoded.include?(user.person.profile.first_name).should be true + it 'FROM: has the name of person commenting as the sender' do + pending + comment_mail.from.should == "\"#{person.name} (Diaspora)\" <#{AppConfig[:smtp_sender_address]}>" end - it 'has the name of person commenting' do - comment_mail.body.encoded.include?(person.name).should be true + it 'SUBJECT: has a snippet of the post contents' do + comment_mail.subject.should == "Re: #{truncate(sm.text, :length => 70)}" end - it 'has the post link in the body' do - comment_mail.body.encoded.include?("#{comment.post.id.to_s}").should be true - end + context 'BODY' do + it "contains the comment" do + comment_mail.body.encoded.should include(comment.text) + end + it "contains the original post's link" do + comment_mail.body.encoded.include?("#{comment.post.id.to_s}").should be true + end + end end - end end |