diff --git a/app/controllers/notifications_controller.rb b/app/controllers/notifications_controller.rb index 28fb48922de06d64d7a5cd0cc5919af212a7248b..deeb59e1b4110f0881bc4b5760149524b37fe0f3 100644 --- a/app/controllers/notifications_controller.rb +++ b/app/controllers/notifications_controller.rb @@ -12,7 +12,7 @@ class NotificationsController < VannaController note = Notification.where(:recipient_id => current_user.id, :id => opts[:id]).first if note note.update_attributes(:unread => opts[:unread] == "true" ) - {} + { :guid => note.id, :unread => note.unread } else Response.new :status => 404 end diff --git a/spec/controllers/notifications_controller_spec.rb b/spec/controllers/notifications_controller_spec.rb index e404334fa0c98acb27e547749c965cb874179072..d7dce0014dace5dcfa680e1e069b87a8c54e0430 100644 --- a/spec/controllers/notifications_controller_spec.rb +++ b/spec/controllers/notifications_controller_spec.rb @@ -30,6 +30,17 @@ describe NotificationsController do Notification.first.unread.should == true end + it 'should return the item guid' do + note = Factory(:notification, :recipient => @user) + answer = @controller.update :id => note.id + answer[:guid].should == note.id + end + it 'should return the unread state' do + note = Factory(:notification, :recipient => @user) + answer = @controller.update :id => note.id, :unread => "true" + answer[:unread].should == true + end + it 'only lets you read your own notifications' do user2 = bob