aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--app/controllers/application_controller.rb5
-rw-r--r--spec/integration/errors_spec.rb17
2 files changed, 21 insertions, 1 deletions
diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb
index 2615b61f2..d1d702616 100644
--- a/app/controllers/application_controller.rb
+++ b/app/controllers/application_controller.rb
@@ -142,7 +142,10 @@ class ApplicationController < ActionController::Base
ExceptionNotifier::Notifier.exception_notification(request.env, exception).deliver
@status = 500
end
- render :template => "general/exception_caught", :status => @status
+ respond_to do |format|
+ format.html{ render :template => "general/exception_caught", :status => @status }
+ format.any{ render :nothing => true, :status => @status }
+ end
end
def local_request?
diff --git a/spec/integration/errors_spec.rb b/spec/integration/errors_spec.rb
index ed0d7bfec..17a0153c2 100644
--- a/spec/integration/errors_spec.rb
+++ b/spec/integration/errors_spec.rb
@@ -62,6 +62,17 @@ describe "When errors occur" do
response.code.should == "500"
end
+ it 'should render a 500 for json errors' do
+ InfoRequest.stub!(:find_by_url_title!).and_raise("An example error")
+ get("/request/example.json")
+ response.code.should == '500'
+ end
+
+ it 'should render a 404 for a non-found xml request' do
+ get("/frobsnasm.xml")
+ response.code.should == '404'
+ end
+
it 'should notify of a general error' do
InfoRequest.stub!(:find_by_url_title!).and_raise("An example error")
get("/request/example")
@@ -97,6 +108,12 @@ describe "When errors occur" do
response.code.should == "403"
end
+ it "return a 403 for a JSON PermissionDenied error" do
+ InfoRequest.stub!(:find_by_url_title!).and_raise(ApplicationController::PermissionDenied)
+ get("/request/example.json")
+ response.code.should == '403'
+ end
+
context "in the admin interface" do
it 'should show a full trace for general errors' do