Skip to content
Extraits de code Groupes Projets
Valider ebb17ff7 rédigé par danielgrippi's avatar danielgrippi Validation de Raphael Sofaer
Parcourir les fichiers

few cucumber steps failing. wip.

parent dfeb4f3a
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
......@@ -8,7 +8,7 @@ module LikesHelper
links.join(", ").html_safe
end
def like_action(post)
def like_action(post, current_user=current_user)
if current_user.liked?(post)
link_to t('shared.stream_element.unlike'), like_path(:post_id => post.id, :id => 'xxx'), :method => :delete, :class => 'unlike', :remote => true
else
......
......@@ -49,6 +49,21 @@ class Notifier < ActionMailer::Base
end
end
def liked(recipient_id, sender_id, like_id)
@receiver = User.find_by_id(recipient_id)
@sender = Person.find_by_id(sender_id)
@like = Like.find(like_id)
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)
end
end
def mentioned(recipient_id, sender_id, target_id)
@receiver = User.find_by_id(recipient_id)
@sender = Person.find_by_id(sender_id)
......
module Job
class MailLiked < Base
@queue = :mail
def self.perform_delegate(recipient_id, sender_id, like_id)
Notifier.liked(recipient_id, sender_id, like_id).deliver
end
end
end
......@@ -39,4 +39,8 @@ class Like < ActiveRecord::Base
def parent= parent
self.post = parent
end
def notification_type(user, person)
Notifications::Liked unless user.person == person
end
end
class Notifications::Liked < Notification
def mail_job
Job::MailLiked
end
def translation_key
'liked'
end
end
......@@ -10,7 +10,8 @@ class UserPreference < ActiveRecord::Base
"private_message",
"request_acceptance",
"request_received",
"also_commented"]
"also_commented",
"liked"]
def must_be_valid_email_type
unless VALID_EMAIL_TYPES.include?(self.email_type)
......
%p
= t('notifier.hello', :name => @receiver.profile.first_name)
%p
= t('.liked', :name => "#{@sender.name} (#{@sender.diaspora_handle})")
%br
= link_to t('.sign_in'), status_message_url(@like.post)
%br
= t('notifier.love')
%br
= t('notifier.diaspora')
!= t('notifier.hello', :name => @receiver.profile.first_name)
!= t('.liked', :name => "#{@sender.name} (#{@sender.diaspora_handle})")
!= link_to t('.sign_in'), status_message_url(@like.post)
!= t('notifier.love')
!= t('notifier.diaspora')
......@@ -39,7 +39,7 @@
- unless (defined?(@commenting_disabled) && @commenting_disabled)
|
%span.like_action
= like_action(post)
= like_action(post, current_user)
|
= link_to t('comments.new_comment.comment'), '#', :class => 'focus_comment_textarea'
......
......@@ -105,6 +105,11 @@
= type.label t('.request_acceptence')
= type.check_box :request_acceptance, {:checked => @email_prefs['request_acceptance']}, false, true
%br
%p.checkbox_select
= type.label t('.liked')
= type.check_box :liked, {:checked => @email_prefs['liked']}, false, true
%br
= f.submit t('.change')
......
......@@ -341,6 +341,10 @@ en:
private_message: "has sent you a private message:"
message_subject: "Subject: %{subject}"
sign_in: "Sign in to view it."
liked:
subject: "%{name} has just liked your post"
liked: "%{name} has just liked your post"
sign_in: "Sign to view it"
people:
zero: "no people"
......@@ -620,6 +624,7 @@ en:
request_received: "...you receive a new share request?"
request_acceptence: "...your share request is accepted?"
private_message: "...you receive a private message?"
liked: "...someone likes your post?"
change: "Change"
destroy: "Account successfully closed."
getting_started:
......
......@@ -86,7 +86,6 @@ describe Notifier do
end
end
describe ".mentioned" do
before do
@user = alice
......@@ -100,11 +99,11 @@ describe Notifier do
end
it 'has the receivers name in the body' do
@mail.body.encoded.include?(@user.person.profile.first_name).should be true
@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
@mail.body.encoded.include?(@sm.author.name).should be_true
end
it 'has the post text in the body' do
......@@ -116,6 +115,30 @@ describe Notifier do
end
end
describe ".liked" do
before do
@sm = Factory(:status_message, :author => alice.person)
@like = @sm.likes.create(:author => bob.person)
@mail = Notifier.liked(alice.id, @like.author.id, @like.id)
end
it '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
end
it 'has the name of person liking in the body' do
@mail.body.encoded.include?(@like.author.name).should be_true
end
it 'should not include translation missing' do
@mail.body.encoded.should_not include("missing")
end
end
describe ".private_message" do
before do
@user2 = bob
......@@ -152,6 +175,7 @@ describe Notifier do
@mail.body.encoded.should_not include("missing")
end
end
context "comments" do
let!(:connect) { connect_users(user, aspect, user2, aspect2)}
let!(:sm) {user.post(:status_message, :text => "Sunny outside", :to => :all)}
......
......@@ -242,13 +242,13 @@ describe User do
alice.disable_mail = true
proc {
alice.update_user_preferences({})
}.should change(alice.user_preferences, :count).by(6)
}.should change(alice.user_preferences, :count).by(7)
end
it 'still sets new prefs to false on update' do
alice.disable_mail = true
proc {
alice.update_user_preferences({'mentioned' => false})
}.should change(alice.user_preferences, :count).by(5)
}.should change(alice.user_preferences, :count).by(6)
alice.reload.disable_mail.should be_false
end
end
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter