mark requests as read when a user responds to the request

This commit is contained in:
danielvincent 2010-12-21 10:31:18 -08:00
parent c17425b7fb
commit a1f3ab3046
2 changed files with 14 additions and 0 deletions

View file

@ -20,6 +20,10 @@ 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)

View file

@ -105,6 +105,16 @@ describe Diaspora::UserModules::Connecting do
user.accept_contact_request(@received_request, aspect)
}.should change(Request, :count ).by(-1)
end
it "should mark the corresponding notification as 'read'" do
notification = Notification.create(:target_id => @received_request.id,
:kind => 'new_request',
:unread => true)
Notification.first(:target_id=>@received_request.id).unread.should be_true
user.accept_contact_request(@received_request, aspect)
Notification.first(:target_id=>@received_request.id).unread.should be_false
end
it 'should be able to ignore a pending contact request' do
proc { user.ignore_contact_request(@received_request.id)
}.should change(Request, :count ).by(-1)