diff options
author | Louise Crow <louise.crow@gmail.com> | 2013-06-20 14:47:56 -0700 |
---|---|---|
committer | Louise Crow <louise.crow@gmail.com> | 2013-06-20 14:50:13 -0700 |
commit | e2fe79fa339a55e02a47ffe6f7e41d498ceb6cb8 (patch) | |
tree | 7555b4e3ba1a398cfea36c152e13900dcb135ffd | |
parent | f46aa93f924f0605fd5426bc164bdbc3455b2ebc (diff) |
Respond to a (currently unsupported) json request for a public body list with a 406, not a 500 caused by a missing template.
-rw-r--r-- | app/controllers/public_body_controller.rb | 4 | ||||
-rw-r--r-- | spec/controllers/public_body_controller_spec.rb | 5 |
2 files changed, 7 insertions, 2 deletions
diff --git a/app/controllers/public_body_controller.rb b/app/controllers/public_body_controller.rb index 74ea043bb..374866eda 100644 --- a/app/controllers/public_body_controller.rb +++ b/app/controllers/public_body_controller.rb @@ -131,7 +131,9 @@ class PublicBodyController < ApplicationController @public_bodies = PublicBody.where(conditions).joins(:translations).order("public_body_translations.name").paginate( :page => params[:page], :per_page => 100 ) - render :template => "public_body/list" + respond_to do |format| + format.html { render :template => "public_body/list" } + end end end diff --git a/spec/controllers/public_body_controller_spec.rb b/spec/controllers/public_body_controller_spec.rb index 22d8418c9..e01bcb0a6 100644 --- a/spec/controllers/public_body_controller_spec.rb +++ b/spec/controllers/public_body_controller_spec.rb @@ -183,8 +183,11 @@ describe PublicBodyController, "when listing bodies" do response.should render_template('list') assigns[:public_bodies].should == [ public_bodies(:humpadink_public_body) ] assigns[:tag].should == "eats_cheese:stilton" + end - + it 'should return a "406 Not Acceptable" code if asked for a json version of a list' do + get :list, :format => 'json' + response.code.should == '406' end end |