mark notification as read on the status message show page
This commit is contained in:
parent
7a667abc73
commit
a6c1b5bf59
3 changed files with 24 additions and 7 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in a new issue