From c19ebcece3970b25a1db6221655c898c763159c2 Mon Sep 17 00:00:00 2001 From: Sarah Mei Date: Wed, 17 Nov 2010 22:28:24 -0800 Subject: [PATCH] Request delete now returns head :ok instead of redirecting. On client side, request div is removed. --- app/controllers/requests_controller.rb | 2 +- features/manages_contact_requests.feature | 10 +++++++++- public/javascripts/aspect-edit.js | 3 +++ spec/controllers/requests_controller_spec.rb | 7 ++++++- 4 files changed, 19 insertions(+), 3 deletions(-) diff --git a/app/controllers/requests_controller.rb b/app/controllers/requests_controller.rb index 0980c16c2..88c3ab97e 100644 --- a/app/controllers/requests_controller.rb +++ b/app/controllers/requests_controller.rb @@ -23,7 +23,7 @@ class RequestsController < ApplicationController else current_user.ignore_contact_request params[:id] flash[:notice] = I18n.t 'requests.destroy.ignore' - respond_with :location => requests_url + head :ok end end diff --git a/features/manages_contact_requests.feature b/features/manages_contact_requests.feature index 876ea754e..dd486ade5 100644 --- a/features/manages_contact_requests.feature +++ b/features/manages_contact_requests.feature @@ -18,4 +18,12 @@ Feature: managing contact requests When I drag the contact request to the "Family" aspect And I wait for the ajax to finish - Then I should see 1 contact in "Family" + Then I should see 1 contact in "Family" + + @javascript @wip + Scenario: ignoring a contact request + When I am on the aspects manage page + Then I should see 1 contact request + When I click "X" on the contact request + And I wait for the ajax to finish + Then I should see 0 contact requests \ No newline at end of file diff --git a/public/javascripts/aspect-edit.js b/public/javascripts/aspect-edit.js index 7c47396af..2c8005815 100644 --- a/public/javascripts/aspect-edit.js +++ b/public/javascripts/aspect-edit.js @@ -140,6 +140,9 @@ var AspectEdit = { type: "DELETE", url: "/requests/" + request_id, success: function () { + person.fadeOut(400, function() { + person.remove(); + }); AspectEdit.decrementRequestsCounter(); } }); diff --git a/spec/controllers/requests_controller_spec.rb b/spec/controllers/requests_controller_spec.rb index b7b11c85b..4df765d57 100644 --- a/spec/controllers/requests_controller_spec.rb +++ b/spec/controllers/requests_controller_spec.rb @@ -35,7 +35,12 @@ describe RequestsController do describe 'when ignoring a contact request' do it "succeeds" do xhr :delete, :destroy, "id" => @friend_request.id.to_s - response.should redirect_to(requests_path) + response.should be_success + end + it "removes the request object" do + lambda { + xhr :delete, :destroy, "id" => @friend_request.id.to_s + }.should change(Request, 'count').by(-1) end end end