diff options
author | Gareth Rees <gareth@mysociety.org> | 2014-08-21 15:51:15 +0100 |
---|---|---|
committer | Gareth Rees <gareth@mysociety.org> | 2014-08-21 15:51:15 +0100 |
commit | 69c700d1ff12bb798569e00f8bf91c539b0ae336 (patch) | |
tree | f2cc3d5f57772b46738f1a7a6ab20fb8b5ca8739 | |
parent | 721a546dfc9b3c461505f51a0cf036ec1c31ce69 (diff) | |
parent | 23a2f7f147ae49f35aa573c2dc68e33c43178471 (diff) |
Merge branch 'issues/1181-destroy-external-request' into rails-3-develop
-rw-r--r-- | app/controllers/admin_request_controller.rb | 3 | ||||
-rw-r--r-- | spec/controllers/admin_request_controller_spec.rb | 6 |
2 files changed, 8 insertions, 1 deletions
diff --git a/app/controllers/admin_request_controller.rb b/app/controllers/admin_request_controller.rb index 5c45a6e6e..21120e4ad 100644 --- a/app/controllers/admin_request_controller.rb +++ b/app/controllers/admin_request_controller.rb @@ -100,7 +100,8 @@ class AdminRequestController < AdminController @info_request.fully_destroy # expire cached files expire_for_request(@info_request) - flash[:notice] = "Request #{url_title} has been completely destroyed. Email of user who made request: " + user.email + email = user.try(:email) ? user.email : 'This request is external so has no associated user' + flash[:notice] = "Request #{ url_title } has been completely destroyed. Email of user who made request: #{ email }" redirect_to admin_request_list_url end diff --git a/spec/controllers/admin_request_controller_spec.rb b/spec/controllers/admin_request_controller_spec.rb index 63b219c88..7c5253f49 100644 --- a/spec/controllers/admin_request_controller_spec.rb +++ b/spec/controllers/admin_request_controller_spec.rb @@ -60,6 +60,12 @@ describe AdminRequestController, "when administering requests" do get :fully_destroy, { :id => info_request } end + it 'uses a different flash message to avoid trying to fetch a non existent user record' do + info_request = info_requests(:external_request) + post :fully_destroy, { :id => info_request.id } + request.flash[:notice].should include('external') + end + end end |