notifications controller should return the guid and unread state of the updated notification
This commit is contained in:
parent
a1d474111b
commit
f72a4b4476
2 changed files with 12 additions and 1 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue