Skip to content
Extraits de code Groupes Projets
Valider f92dd857 rédigé par Erwan Guyader's avatar Erwan Guyader
Parcourir les fichiers

Set sharing notification as read

  Fix issue #4951

  If the displayed user (on her profile) started sharing with the
current user, mark the notification as read
parent 773340de
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
...@@ -77,6 +77,8 @@ class PeopleController < ApplicationController ...@@ -77,6 +77,8 @@ class PeopleController < ApplicationController
authenticate_user! if remote_profile_with_no_user_session? authenticate_user! if remote_profile_with_no_user_session?
raise Diaspora::AccountClosed if @person.closed_account? raise Diaspora::AccountClosed if @person.closed_account?
mark_corresponding_notifications_read if user_signed_in?
@post_type = :all @post_type = :all
@aspect = :profile @aspect = :profile
@stream = Stream::Person.new(current_user, @person, :max_time => max_time) @stream = Stream::Person.new(current_user, @person, :max_time => max_time)
...@@ -201,4 +203,10 @@ class PeopleController < ApplicationController ...@@ -201,4 +203,10 @@ class PeopleController < ApplicationController
photos.order('created_at desc') photos.order('created_at desc')
end end
def mark_corresponding_notifications_read
Notification.where(recipient_id: current_user.id, target_type: "Person", target_id: @person.id, unread: true).each do |n|
n.set_read_state( true )
end
end
end end
...@@ -323,6 +323,15 @@ describe PeopleController do ...@@ -323,6 +323,15 @@ describe PeopleController do
get :show, :id => @user.person.to_param get :show, :id => @user.person.to_param
assigns[:stream].posts.map { |x| x.id }.should include(reshare.id) assigns[:stream].posts.map { |x| x.id }.should include(reshare.id)
end end
it 'marks a corresponding notifications as read' do
note = FactoryGirl.create(:notification, :recipient => @user, :target => @person, :unread => true)
expect {
get :show, :id => @person.to_param
note.reload
}.to change(Notification.where(:unread => true), :count).by(-1)
end
end end
context "when the person is not a contact of the current user" do context "when the person is not a contact of the current user" do
......
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