diff --git a/app/controllers/requests_controller.rb b/app/controllers/requests_controller.rb index 46d8bce1820f705fb79241474e3cd3d507a5eba4..ac2a1e2e328c7f2d59bbc8cc95cf89f1625991e7 100644 --- a/app/controllers/requests_controller.rb +++ b/app/controllers/requests_controller.rb @@ -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]) diff --git a/lib/diaspora/user/connecting.rb b/lib/diaspora/user/connecting.rb index ed7b7b3f56c021a8ebfe7823a2c5fc1999949ca7..d866f2e0b224678251ae8e2e18643fcf3ce36bdb 100644 --- a/lib/diaspora/user/connecting.rb +++ b/lib/diaspora/user/connecting.rb @@ -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) diff --git a/spec/controllers/requests_controller_spec.rb b/spec/controllers/requests_controller_spec.rb index bf52f7685f7343ada37a0dc24ac71a19659f7049..b14b95491cf76612383bfc83fbb642236a7c6322 100644 --- a/spec/controllers/requests_controller_spec.rb +++ b/spec/controllers/requests_controller_spec.rb @@ -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