fixed emails to show avatars, have subject lines that allow threading in email clients, and relevant content previews
This commit is contained in:
parent
8cfd2e02e1
commit
c4b715f3ff
20 changed files with 155 additions and 242 deletions
|
|
@ -15,9 +15,13 @@ module MarkdownifyHelper
|
|||
message = process_youtube(message, options[:youtube_maps])
|
||||
message = process_vimeo(message, options[:vimeo_maps])
|
||||
message = process_emoticons(message) if options[:emoticons]
|
||||
message = process_newlines(message) if options[:newlines]
|
||||
|
||||
message.gsub!(/\n+/, '<br />') if options[:newlines]
|
||||
message
|
||||
end
|
||||
|
||||
def process_newlines(message)
|
||||
message.gsub!(/\n+/, '<br />')
|
||||
message
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -1,8 +1,12 @@
|
|||
class Notifier < ActionMailer::Base
|
||||
helper :application
|
||||
helper :markdownify
|
||||
|
||||
default :from => AppConfig[:smtp_sender_address]
|
||||
|
||||
ATTACHMENT = File.read("#{Rails.root}/public/images/logo_caps.png")
|
||||
include ActionView::Helpers::TextHelper
|
||||
|
||||
TRUNCATION_LEN = 70
|
||||
|
||||
def self.admin(string, recipients, opts = {})
|
||||
mails = []
|
||||
|
|
@ -16,7 +20,6 @@ class Notifier < ActionMailer::Base
|
|||
def single_admin(string, recipient)
|
||||
@receiver = recipient
|
||||
@string = string.html_safe
|
||||
attachments.inline['logo_caps.png'] = ATTACHMENT
|
||||
mail(:to => @receiver.email,
|
||||
:subject => I18n.t('notifier.single_admin.subject'), :host => AppConfig[:pod_uri].host)
|
||||
end
|
||||
|
|
@ -27,8 +30,6 @@ class Notifier < ActionMailer::Base
|
|||
|
||||
log_mail(recipient_id, sender_id, 'started_sharing')
|
||||
|
||||
attachments.inline['logo_caps.png'] = ATTACHMENT
|
||||
|
||||
I18n.with_locale(@receiver.language) do
|
||||
mail(:to => "\"#{@receiver.name}\" <#{@receiver.email}>",
|
||||
:subject => I18n.t('notifier.started_sharing.subject', :name => @sender.name), :host => AppConfig[:pod_uri].host)
|
||||
|
|
@ -42,11 +43,9 @@ class Notifier < ActionMailer::Base
|
|||
|
||||
log_mail(recipient_id, sender_id, 'liked')
|
||||
|
||||
attachments.inline['logo_caps.png'] = ATTACHMENT
|
||||
|
||||
I18n.with_locale(@receiver.language) do
|
||||
mail(:to => "\"#{@receiver.name}\" <#{@receiver.email}>",
|
||||
:subject => I18n.t('notifier.liked.subject', :name => @sender.name), :host => AppConfig[:pod_uri].host)
|
||||
:subject => I18n.t('notifier.liked.liked', :name => @sender.name), :host => AppConfig[:pod_uri].host)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -57,8 +56,6 @@ class Notifier < ActionMailer::Base
|
|||
|
||||
log_mail(recipient_id, sender_id, 'mentioned')
|
||||
|
||||
attachments.inline['logo_caps.png'] = ATTACHMENT
|
||||
|
||||
I18n.with_locale(@receiver.language) do
|
||||
mail(:to => "\"#{@receiver.name}\" <#{@receiver.email}>",
|
||||
:subject => I18n.t('notifier.mentioned.subject', :name => @sender.name), :host => AppConfig[:pod_uri].host)
|
||||
|
|
@ -72,11 +69,10 @@ class Notifier < ActionMailer::Base
|
|||
|
||||
log_mail(recipient_id, sender_id, 'comment_on_post')
|
||||
|
||||
attachments.inline['logo_caps.png'] = ATTACHMENT
|
||||
|
||||
I18n.with_locale(@receiver.language) do
|
||||
mail(:to => "\"#{@receiver.name}\" <#{@receiver.email}>",
|
||||
:subject => I18n.t('notifier.comment_on_post.subject', :name => @sender.name), :host => AppConfig[:pod_uri].host)
|
||||
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)}")
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -89,11 +85,10 @@ class Notifier < ActionMailer::Base
|
|||
|
||||
log_mail(recipient_id, sender_id, 'comment_on_post')
|
||||
|
||||
attachments.inline['logo_caps.png'] = ATTACHMENT
|
||||
|
||||
I18n.with_locale(@receiver.language) do
|
||||
mail(:to => "\"#{@receiver.name}\" <#{@receiver.email}>",
|
||||
:subject => I18n.t('notifier.also_commented.subject', :name => @sender.name, :post_author => @post_author_name ), :host => AppConfig[:pod_uri].host)
|
||||
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)}")
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -107,11 +102,14 @@ class Notifier < ActionMailer::Base
|
|||
|
||||
log_mail(recipient_id, sender_id, 'private_message')
|
||||
|
||||
attachments.inline['logo_caps.png'] = ATTACHMENT
|
||||
subject = @conversation.subject.strip
|
||||
subject = "Re: #{subject}" if @conversation.messages.size > 1
|
||||
|
||||
|
||||
I18n.with_locale(@receiver.language) do
|
||||
mail(:to => "\"#{@receiver.name}\" <#{@receiver.email}>",
|
||||
:subject => I18n.t('notifier.private_message.subject', :name => @sender.name), :host => AppConfig[:pod_uri].host)
|
||||
mail(:from => "\"#{@sender.name} (Diaspora)\" <#{AppConfig[:smtp_sender_address]}>",
|
||||
:to => "\"#{@receiver.name}\" <#{@receiver.email}>",
|
||||
:subject => subject)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
|||
36
app/views/layouts/notifier.html.erb
Normal file
36
app/views/layouts/notifier.html.erb
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
<table cellspacing="0" cellpadding="0" border="0" align="center" width="100%" style="font-family:'Helvetica Neue', Helvetica, Arial, sans-serif;font-size:14px;color:#333;">
|
||||
<table cellspacing="0" cellpadding="0" border="0" align="center" width="100%" style="font-family:'Helvetica Neue', Helvetica, Arial, sans-serif;font-size:14px;color:#333;">
|
||||
<tr width="100%">
|
||||
<% if @sender %>
|
||||
<td style="vertical-align:top;" width="80px">
|
||||
<div style="background-color:#eee;height:70px;width:70px;">
|
||||
<img alt="<%=@sender.name%>" src="<%=@sender.profile.image_url(:medium)%>" style="border:0;display:block;display:relative;top:0;left:0;" height="70px" width="70px">
|
||||
</div>
|
||||
</td>
|
||||
<% end %>
|
||||
<td style="vertical-align:top;">
|
||||
<%= yield %>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<table cellspacing="0" cellpadding="0" border="0" align="center" width="100%" style="font-family:'Helvetica Neue', Helvetica, Arial, sans-serif;font-size:12px;color:#999; padding-top:10px; margin-top:10px; border-top: 1px solid #ddd;">
|
||||
<tr>
|
||||
<td>
|
||||
<%= t('notifier.email_sent_by_diaspora') %>
|
||||
<a href="<%=edit_user_url%>">
|
||||
<%= t('notifier.click_here') %>
|
||||
</a>
|
||||
<%=t('notifier.to_change_your_notification_settings')%>.
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<table cellspacing="0" cellpadding="0" border="0" align="center" width="100%" style="font-family:'Helvetica Neue', Helvetica, Arial, sans-serif;font-size:14px;color:#333;">
|
||||
<tr>
|
||||
<td style="text-align:center;padding:30px;">
|
||||
<img src="<%=AppConfig[:pod_url]%>images/logo_caps.png" alt="DIASPORA*" width="95px" height="14px"/>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</table>
|
||||
|
||||
|
|
@ -1,12 +0,0 @@
|
|||
!!!
|
||||
%html
|
||||
%head
|
||||
%meta{"http-equiv"=>"Content-Type", :content=>"text/html; charset=utf-8"}/
|
||||
= render :partial => 'notifier_css'
|
||||
%body
|
||||
%header
|
||||
= image_tag attachments['logo_caps.png'].url, :alt => "DIASPORA"
|
||||
#container
|
||||
= yield
|
||||
%a{:href => "#{AppConfig[:pod_uri].scheme}://#{AppConfig[:pod_uri].host}#{edit_user_path}"}
|
||||
= t('notifier.manage_your_email_settings')
|
||||
|
|
@ -1,3 +1,4 @@
|
|||
!= yield
|
||||
!= t('notifier.manage_your_email_settings')
|
||||
!= "#{AppConfig[:pod_uri].scheme}://#{AppConfig[:pod_uri].host}#{edit_user_path}"
|
||||
!= t('notifier.email_sent_by_diaspora')
|
||||
!= t('notifier.to_change_your_notification_settings')
|
||||
!= edit_user_url
|
||||
|
|
|
|||
|
|
@ -1,14 +1,9 @@
|
|||
:css
|
||||
body{
|
||||
width:600px;
|
||||
font-family:'Arial','Helvetica',sans-serif;
|
||||
font-size:14px;
|
||||
color:#333;
|
||||
font-family: 'Helvetica',sans-serif;
|
||||
}
|
||||
#container{
|
||||
margin-bottom:25px
|
||||
min-height:400px;
|
||||
padding-left:15px;
|
||||
}
|
||||
header{
|
||||
margin-bottom: 25px;
|
||||
|
|
@ -31,7 +26,3 @@
|
|||
a:active{
|
||||
color: #005D9C;
|
||||
}
|
||||
.large_text{
|
||||
font-size:21px;
|
||||
font-family:"Helvetica Neue",Arial,Helvetica,sans-serif;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,17 +1,4 @@
|
|||
%p
|
||||
= t('notifier.hello', :name => @receiver.profile.first_name)
|
||||
= process_newlines(truncate(@comment.text, :length => 600))
|
||||
%p
|
||||
= "#{@sender.name} (#{@sender.diaspora_handle})"
|
||||
= t('.commented', :post_author => @post_author_name)
|
||||
%br
|
||||
%br
|
||||
= @comment.text
|
||||
|
||||
%br
|
||||
%br
|
||||
= link_to t('.sign_in'), post_url(@comment.post)
|
||||
|
||||
%br
|
||||
= t('notifier.love')
|
||||
%br
|
||||
= t('notifier.diaspora')
|
||||
= link_to t('notifier.comment_on_post.reply', :name => @comment.post.author.first_name), post_url(@comment.post)
|
||||
|
|
|
|||
|
|
@ -1,8 +1 @@
|
|||
!= t('notifier.hello', :name => @receiver.profile.first_name)
|
||||
!= "#{@sender.name} (#{@sender.diaspora_handle})"
|
||||
!= t('notifier.also_commented.commented', :post_author => @post_author_name)
|
||||
|
||||
!= @comment.text
|
||||
|
||||
!= "#{t('notifier.love')} \n"
|
||||
!= t('notifier.diaspora')
|
||||
!= truncate(@comment.text, :length => 600)
|
||||
|
|
|
|||
|
|
@ -1,15 +1,4 @@
|
|||
%p
|
||||
= t('notifier.hello', :name => @receiver.profile.first_name)
|
||||
= process_newlines(truncate(@comment.text, :length => 600))
|
||||
%p
|
||||
= "#{@sender.name} (#{@sender.diaspora_handle})"
|
||||
= t('.commented')
|
||||
|
||||
= @comment.text
|
||||
|
||||
%br
|
||||
= link_to t('.sign_in'), post_url(@comment.post)
|
||||
|
||||
%br
|
||||
= t('notifier.love')
|
||||
%br
|
||||
= t('notifier.diaspora')
|
||||
= link_to t('notifier.comment_on_post.reply', :name => @comment.post.author.name), post_url(@comment.post)
|
||||
|
|
|
|||
|
|
@ -1,10 +1 @@
|
|||
!= t('notifier.hello', :name => @receiver.profile.first_name)
|
||||
!= "#{@sender.name} (#{@sender.diaspora_handle})"
|
||||
!= t('notifier.comment_on_post.commented')
|
||||
|
||||
!= @comment.text
|
||||
|
||||
!= post_url(@comment.post)
|
||||
|
||||
!= "#{t('notifier.love')} \n"
|
||||
!= t('notifier.diaspora')
|
||||
!= truncate(@comment.text, :length => 600)
|
||||
|
|
|
|||
|
|
@ -1,15 +1,8 @@
|
|||
%p
|
||||
= t('notifier.hello', :name => @receiver.profile.first_name)
|
||||
%p
|
||||
= t('.liked', :name => "#{@sender.name} (#{@sender.diaspora_handle})")
|
||||
= "#{t('.liked', :name => "#{@sender.name}")}:"
|
||||
|
||||
%p{:style => "font-style:italic;color:#666"}
|
||||
= process_newlines(truncate(@like.target.formatted_message(:plain_text => true), :length => 200))
|
||||
|
||||
%p
|
||||
= @like.target.formatted_message(:plain_text => true)
|
||||
%p
|
||||
|
||||
%br
|
||||
= link_to t('.sign_in'), post_url(@like.target)
|
||||
%br
|
||||
= t('notifier.love')
|
||||
%br
|
||||
= t('notifier.diaspora')
|
||||
= link_to t('.view_post'), post_url(@like.target)
|
||||
|
|
|
|||
|
|
@ -1,8 +1,3 @@
|
|||
!= t('notifier.hello', :name => @receiver.profile.first_name)
|
||||
!= "#{t('notifier.liked.liked', :name => "#{@sender.name}")}:"
|
||||
!= truncate(@like.target.formatted_message(:plain_text => true), :length => 200)
|
||||
|
||||
!= t('notifier.liked.liked', :name => "#{@sender.name} (#{@sender.diaspora_handle})")
|
||||
|
||||
!= @like.target.formatted_message(:plain_text => true)
|
||||
|
||||
!= t('notifier.love')
|
||||
!= t('notifier.diaspora')
|
||||
|
|
|
|||
|
|
@ -1,16 +1,4 @@
|
|||
%p
|
||||
= t('notifier.hello', :name => @receiver.profile.first_name)
|
||||
= process_newlines(truncate(@post.formatted_message(:plain_text => true), :length => 600))
|
||||
%p
|
||||
= "#{@sender.name} (#{@sender.diaspora_handle})"
|
||||
= t('.mentioned')
|
||||
%p
|
||||
= @post.formatted_message(:plain_text => true)
|
||||
%p
|
||||
|
||||
%br
|
||||
= link_to t('.sign_in'), post_url(@post)
|
||||
|
||||
%br
|
||||
= t('notifier.love')
|
||||
%br
|
||||
= t('notifier.diaspora')
|
||||
= link_to t('notifier.comment_on_post.reply', :name => @post.author.name), post_url(@post)
|
||||
|
|
|
|||
|
|
@ -1,8 +1 @@
|
|||
!= t('notifier.hello', :name => @receiver.profile.first_name)
|
||||
!= "#{@sender.name} (#{@sender.diaspora_handle})"
|
||||
!= t('notifier.mentioned.mentioned')
|
||||
|
||||
!= @post.formatted_message(:plain_text => true)
|
||||
|
||||
!= "#{t('notifier.love')} \n"
|
||||
!= t('notifier.diaspora')
|
||||
|
|
|
|||
|
|
@ -1,18 +1,4 @@
|
|||
%p
|
||||
= t('notifier.hello', :name => @receiver.profile.first_name)
|
||||
= markdownify(@message.text)
|
||||
%p
|
||||
= "#{@sender.name} (#{@sender.diaspora_handle})"
|
||||
= t('.private_message')
|
||||
%p
|
||||
= t('.message_subject', :subject => @conversation.subject)
|
||||
%p
|
||||
= @message.text
|
||||
%p
|
||||
|
||||
%br
|
||||
= link_to t('.sign_in'), conversations_url(:conversation_id => @conversation)
|
||||
|
||||
%br
|
||||
= t('notifier.love')
|
||||
%br
|
||||
= t('notifier.diaspora')
|
||||
= link_to t('.reply_to_or_view'), conversations_url(:conversation_id => @conversation)
|
||||
|
|
|
|||
|
|
@ -1,9 +1 @@
|
|||
!= t('notifier.hello', :name => @receiver.profile.first_name)
|
||||
!= "#{@sender.name} (#{@sender.diaspora_handle})"
|
||||
!= t('notifier.private_message.private_message')
|
||||
|
||||
!= t('notifier.private_message.message_subject', :subject => @conversation.subject)
|
||||
!= @message.text
|
||||
|
||||
!= "#{t('notifier.love')} \n"
|
||||
!= t('notifier.diaspora')
|
||||
|
|
|
|||
|
|
@ -1,12 +1,5 @@
|
|||
%p
|
||||
= t('notifier.hello', :name => @receiver.profile.first_name)
|
||||
%p
|
||||
= "#{@sender.name} (#{@sender.diaspora_handle})"
|
||||
= @sender.name
|
||||
= t('.sharing')
|
||||
|
||||
%br
|
||||
= link_to t('.sign_in'), new_user_session_url
|
||||
%br
|
||||
= t('notifier.love')
|
||||
%br
|
||||
= t('notifier.diaspora')
|
||||
%p
|
||||
= link_to t('.view_profile', :name => @sender.first_name), person_url(@sender)
|
||||
|
|
|
|||
|
|
@ -1,8 +1,4 @@
|
|||
!= t('notifier.hello', :name => @receiver.profile.first_name)
|
||||
!= "#{@sender.name} (#{@sender.diaspora_handle})"
|
||||
!= "#{@sender.name}"
|
||||
!= t('notifier.started_sharing.sharing')
|
||||
|
||||
!= t('.sign_in')
|
||||
!= new_user_session_url
|
||||
!= "#{t('notifier.love')} \n"
|
||||
!= t('notifier.diaspora')
|
||||
!= t('.view_profile', :name => @sender.first_name)
|
||||
!= person_url(@sender)
|
||||
|
|
|
|||
|
|
@ -397,39 +397,28 @@ en:
|
|||
other: "%{count} new notifications"
|
||||
|
||||
notifier:
|
||||
email_sent_by_diaspora: "This email was sent by Diaspora. If you'd like to stop getting emails like this,"
|
||||
click_here: "click here"
|
||||
hello: "Hello %{name}!"
|
||||
love: "love,"
|
||||
thanks: "Thanks,"
|
||||
diaspora: "the diaspora email robot"
|
||||
manage_your_email_settings: "manage your email settings"
|
||||
to_change_your_notification_settings: "to change your notification settings"
|
||||
single_admin:
|
||||
subject: "A message about your Diaspora account:"
|
||||
admin: "Your Diaspora administrator"
|
||||
started_sharing:
|
||||
subject: "%{name} has started sharing with you on Diaspora*"
|
||||
subject: "%{name} started sharing with you on Diaspora*"
|
||||
sharing: "has started sharing with you!"
|
||||
sign_in: "Sign in here"
|
||||
view_profile: "View %{name}'s profile"
|
||||
comment_on_post:
|
||||
subject: "%{name} has commented on your post."
|
||||
commented: "has commented on your post:"
|
||||
sign_in: "Sign in to view it."
|
||||
also_commented:
|
||||
subject: "%{name} has also commented on %{post_author}'s post."
|
||||
commented: "has also commented on %{post_author}'s post:"
|
||||
sign_in: "Sign in to view it."
|
||||
reply: "Reply or view %{name}'s post >"
|
||||
mentioned:
|
||||
subject: "%{name} has mentioned you on Diaspora*"
|
||||
mentioned: "mentioned you in a post:"
|
||||
sign_in: "Sign in to view it."
|
||||
private_message:
|
||||
subject: "%{name} has sent you a private message on Diaspora*"
|
||||
private_message: "has sent you a private message:"
|
||||
message_subject: "Subject: %{subject}"
|
||||
sign_in: "Sign in to view it."
|
||||
reply_to_or_view: "Reply to or view this conversation >"
|
||||
liked:
|
||||
subject: "%{name} has just liked your post"
|
||||
liked: "%{name} has just liked your post: "
|
||||
sign_in: "Sign in to view it"
|
||||
liked: "%{name} just liked your post:"
|
||||
view_post: "View post >"
|
||||
|
||||
people:
|
||||
zero: "no people"
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
@ -78,16 +75,13 @@ describe Notifier do
|
|||
|
||||
@mail = Notifier.mentioned(@user.id, @sm.author.id, @m.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 receivers name in the body' do
|
||||
@mail.body.encoded.include?(@user.person.profile.first_name).should be_true
|
||||
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
|
||||
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
|
||||
describe ".also commented" do
|
||||
end
|
||||
|
||||
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
|
||||
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
|
||||
|
|
|
|||
Loading…
Reference in a new issue