aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGareth Rees <gareth@mysociety.org>2014-08-18 16:29:42 +0100
committerGareth Rees <gareth@mysociety.org>2014-08-18 16:29:42 +0100
commit96e0815eedaa93bceaab176b50271ee8742aba8a (patch)
tree8efe4ddf81a7f5eb1aeab172e7f456ccadfed00c
parenta4d343096231d62e8d91a1b23ba9e1997e9136c0 (diff)
Use different flash for fully_destroy external InfoRequest
Uses a different flash message to avoid trying to fetch a non existent user record
-rw-r--r--app/controllers/admin_request_controller.rb3
-rw-r--r--spec/controllers/admin_request_controller_spec.rb6
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..8a5f1bd14 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