Revert "Revert "added comment on post mail method""
This reverts commit c9b3066599.
This commit is contained in:
parent
c9b3066599
commit
7254db5cbc
4 changed files with 45 additions and 1 deletions
|
|
@ -1,4 +1,5 @@
|
||||||
class Notifier < ActionMailer::Base
|
class Notifier < ActionMailer::Base
|
||||||
|
helper :application
|
||||||
|
|
||||||
default :from => AppConfig[:smtp_sender_address]
|
default :from => AppConfig[:smtp_sender_address]
|
||||||
|
|
||||||
|
|
@ -45,6 +46,18 @@ class Notifier < ActionMailer::Base
|
||||||
:subject => I18n.t('notifier.request_accepted.subject', :name => @sender.name), :host => AppConfig[:pod_uri].host)
|
:subject => I18n.t('notifier.request_accepted.subject', :name => @sender.name), :host => AppConfig[:pod_uri].host)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def comment_on_post(recipient_id, sender_id, comment)
|
||||||
|
@receiver = User.find_by_id(recipient_id)
|
||||||
|
@sender = Person.find_by_id(sender_id)
|
||||||
|
|
||||||
|
log_mail(recipient_id, sender_id, 'comment_on_post')
|
||||||
|
|
||||||
|
attachments.inline['diaspora_white_on_grey.png'] = ATTACHMENT
|
||||||
|
|
||||||
|
mail(:to => "\"#{@receiver.name}\" <#{@receiver.email}>",
|
||||||
|
:subject => I18n.t('notifier.comment_on_post.subject', :name => @sender.name), :host => AppConfig[:pod_uri].host)
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
def log_mail recipient_id, sender_id, type
|
def log_mail recipient_id, sender_id, type
|
||||||
log_string = "event=mail mail_type=#{type} db_name=#{MongoMapper.database.name} recipient_id=#{recipient_id} sender_id=#{sender_id}"
|
log_string = "event=mail mail_type=#{type} db_name=#{MongoMapper.database.name} recipient_id=#{recipient_id} sender_id=#{sender_id}"
|
||||||
|
|
|
||||||
|
|
@ -432,6 +432,10 @@ en:
|
||||||
request_accepted:
|
request_accepted:
|
||||||
subject: "%{name} has accepted your contact request on Diaspora*"
|
subject: "%{name} has accepted your contact request on Diaspora*"
|
||||||
accepted: "has accepted your contact request!"
|
accepted: "has accepted your contact request!"
|
||||||
|
comment_on_post:
|
||||||
|
subject: "%{name} has commented on your post."
|
||||||
|
commented: "has commented on your post!"
|
||||||
|
sign_in: "Sign in to view it."
|
||||||
home:
|
home:
|
||||||
show:
|
show:
|
||||||
share_what_you_want: "Share what you want, with whom you want."
|
share_what_you_want: "Share what you want, with whom you want."
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,10 @@ require 'spec_helper'
|
||||||
describe Notifier do
|
describe Notifier do
|
||||||
|
|
||||||
let!(:user) {make_user}
|
let!(:user) {make_user}
|
||||||
|
let!(:user2) {make_user}
|
||||||
|
|
||||||
|
let!(:aspect) {user.aspects.create(:name => "win")}
|
||||||
|
let!(:aspect2) {user2.aspects.create(:name => "win")}
|
||||||
let!(:person) {Factory.create :person}
|
let!(:person) {Factory.create :person}
|
||||||
|
|
||||||
before do
|
before do
|
||||||
|
|
@ -76,4 +80,27 @@ describe Notifier do
|
||||||
request_accepted_mail.body.encoded.include?(person.name).should be true
|
request_accepted_mail.body.encoded.include?(person.name).should be true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe "#comment_on_post" do
|
||||||
|
let!(:connect) { connect_users(user, aspect, user2, aspect2)}
|
||||||
|
let!(:sm) {user.post(:status_message, :message => "Sunny outside", :to => :all)}
|
||||||
|
let!(:comment) { user2.comment("Totally is", :on => sm )}
|
||||||
|
let!(:comment_mail) {Notifier.comment_on_post(user.id, person.id, comment)}
|
||||||
|
|
||||||
|
it '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
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'has the name of person commenting' do
|
||||||
|
comment_mail.body.encoded.include?(person.name).should be true
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'has the post link in the body' do
|
||||||
|
comment_mail.body.encoded.should match "/#{object_path(@sm)}/"
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -92,7 +92,7 @@ describe User do
|
||||||
it 'removes posts upon disconnecting' do
|
it 'removes posts upon disconnecting' do
|
||||||
user.disconnect(user2.person)
|
user.disconnect(user2.person)
|
||||||
user.reload
|
user.reload
|
||||||
user.raw_visible_posts.should_not include @status_message
|
user.raw_visibNotification.notify(self, oble_posts.should_not include @status_message
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'deletes a post if the noone links to it' do
|
it 'deletes a post if the noone links to it' do
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue