From f72a4b4476d2845348f2b021779ed2f042188ac8 Mon Sep 17 00:00:00 2001 From: Steven Fuchs Date: Fri, 23 Dec 2011 22:58:01 -0500 Subject: [PATCH] notifications controller should return the guid and unread state of the updated notification --- app/controllers/notifications_controller.rb | 2 +- spec/controllers/notifications_controller_spec.rb | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/app/controllers/notifications_controller.rb b/app/controllers/notifications_controller.rb index 28fb48922..deeb59e1b 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 e404334fa..d7dce0014 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