Skip to content
Extraits de code Groupes Projets
Valider a6c1b5bf rédigé par zhitomirskiyi's avatar zhitomirskiyi
Parcourir les fichiers

mark notification as read on the status message show page

parent 7a667abc
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
......@@ -73,9 +73,14 @@ class StatusMessagesController < ApplicationController
def show
@status_message = current_user.find_visible_post_by_id params[:id]
@object_aspect_ids = @status_message.aspects.map{|a| a.id}
# mark corresponding notification as read
if notification = Notification.where(:recipient_id => current_user.id, :target_id => @status_message.id).first
notification.unread = false
notification.save
end
respond_with @status_message
end
......
......@@ -35,7 +35,6 @@ describe StatisticsController do
end
end
describe '#redirect_unauthorized' do
it 'redirects for non admins' do
AppConfig[:admins] = ['bob']
......
......@@ -21,15 +21,28 @@ describe StatusMessagesController do
end
describe '#show' do
it 'succeeds' do
message = @user1.build_post :status_message, :message => "ohai", :to => @aspect1.id
message.save!
@user1.add_to_streams(message, [@aspect1])
@user1.dispatch_post message, :to => @aspect1.id
before do
@message = @user1.build_post :status_message, :message => "ohai", :to => @aspect1.id
@message.save!
@user1.add_to_streams(@message, [@aspect1])
@user1.dispatch_post @message, :to => @aspect1.id
end
it 'succeeds' do
get :show, "id" => message.id.to_s
response.should be_success
end
it 'marks a corresponding notification as read' do
alice.comment("comment after me", :on => @message)
bob.comment("here you go", :on => @message)
note = Notification.where(:recipient_id => alice.id, :target_id => @message.id).first
lambda{
get :show, :id => @message.id
note.reload
}.should change(note, :unread).from(true).to(false)
end
end
describe '#create' 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