mark a notification as read when you ignore a request
This commit is contained in:
parent
b528802dc8
commit
d3daa32558
3 changed files with 11 additions and 4 deletions
|
|
@ -11,6 +11,10 @@ class RequestsController < ApplicationController
|
|||
respond_to :html
|
||||
|
||||
def destroy
|
||||
if notification = Notification.where(:user_id => current_user.id, :target_id=> params[:id]).first
|
||||
notification.update_attributes(:unread=>false)
|
||||
end
|
||||
|
||||
if params[:accept]
|
||||
if params[:aspect_id]
|
||||
@contact = current_user.accept_and_respond( params[:id], params[:aspect_id])
|
||||
|
|
|
|||
|
|
@ -20,10 +20,6 @@ module Diaspora
|
|||
end
|
||||
|
||||
def accept_contact_request(request, aspect)
|
||||
if notification = Notification.first(:target_id=>request.id)
|
||||
notification.update_attributes(:unread=>false)
|
||||
end
|
||||
|
||||
activate_contact(request.from, aspect)
|
||||
request.destroy
|
||||
request.reverse_for(self)
|
||||
|
|
|
|||
|
|
@ -46,6 +46,13 @@ describe RequestsController do
|
|||
:id => @friend_request.id.to_s
|
||||
}.should change(Request, :count).by(-1)
|
||||
end
|
||||
it "marks the notification as read" do
|
||||
notification = Notification.where(:user_id => @user.id, :target_id=> @friend_request.id).first
|
||||
notification.reload.unread.should == true
|
||||
xhr :delete, :destroy,
|
||||
:id => @friend_request.id.to_s
|
||||
notification.reload.unread.should == false
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue