notifications controller should return the guid and unread state of the updated notification

This commit is contained in:
Steven Fuchs 2011-12-23 22:58:01 -05:00
parent a1d474111b
commit f72a4b4476
2 changed files with 12 additions and 1 deletions

View file

@ -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

View file

@ -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