From f134cfd43f11e66d9b561b580d50f6f8a68db66e Mon Sep 17 00:00:00 2001 From: zhitomirskiyi Date: Tue, 4 Jan 2011 15:44:39 -0800 Subject: [PATCH] moved the test to the controller --- spec/controllers/requests_controller_spec.rb | 10 ++++++++++ spec/models/user/connecting_spec.rb | 9 --------- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/spec/controllers/requests_controller_spec.rb b/spec/controllers/requests_controller_spec.rb index b14b95491..5ee4fbc92 100644 --- a/spec/controllers/requests_controller_spec.rb +++ b/spec/controllers/requests_controller_spec.rb @@ -33,6 +33,15 @@ describe RequestsController do :id => @friend_request.id.to_s response.should redirect_to(aspect_path(@user.aspects.first)) 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, + :accept => "true", + :aspect_id => @user.aspects.first.id.to_s, + :id => @friend_request.id.to_s + notification.reload.unread.should == false + end end describe 'when ignoring a contact request' do it "succeeds" do @@ -46,6 +55,7 @@ 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 diff --git a/spec/models/user/connecting_spec.rb b/spec/models/user/connecting_spec.rb index d3c696ba5..903a6a503 100644 --- a/spec/models/user/connecting_spec.rb +++ b/spec/models/user/connecting_spec.rb @@ -106,15 +106,6 @@ describe Diaspora::UserModules::Connecting do }.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)