diff --git a/app/controllers/status_messages_controller.rb b/app/controllers/status_messages_controller.rb index 59140ae778bc2eef9c7607b4feceaec5c924ba03..70d8a36d240cb7ece56970aa462d185402770c4d 100644 --- a/app/controllers/status_messages_controller.rb +++ b/app/controllers/status_messages_controller.rb @@ -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 diff --git a/spec/controllers/statistics_controller_spec.rb b/spec/controllers/statistics_controller_spec.rb index f0809b4f9154387f0785be8c639d5a0857432e62..560c6d3d679d11d728eed92c6199bd2d75bb5b53 100644 --- a/spec/controllers/statistics_controller_spec.rb +++ b/spec/controllers/statistics_controller_spec.rb @@ -35,7 +35,6 @@ describe StatisticsController do end end - describe '#redirect_unauthorized' do it 'redirects for non admins' do AppConfig[:admins] = ['bob'] diff --git a/spec/controllers/status_message_controller_spec.rb b/spec/controllers/status_message_controller_spec.rb index 2b4f1926ec0e8b24ea923d068c24bcbbf58252fc..62754b89ee5b024867f06dae796721c375bc12bd 100644 --- a/spec/controllers/status_message_controller_spec.rb +++ b/spec/controllers/status_message_controller_spec.rb @@ -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