diff options
Diffstat (limited to 'spec/controllers/public_body_controller_spec.rb')
-rw-r--r-- | spec/controllers/public_body_controller_spec.rb | 25 |
1 files changed, 16 insertions, 9 deletions
diff --git a/spec/controllers/public_body_controller_spec.rb b/spec/controllers/public_body_controller_spec.rb index 0050678d2..0ac2726ea 100644 --- a/spec/controllers/public_body_controller_spec.rb +++ b/spec/controllers/public_body_controller_spec.rb @@ -7,47 +7,54 @@ describe PublicBodyController, "when showing a body" do fixtures :public_bodies, :public_body_translations, :public_body_versions it "should be successful" do - get :show, :url_name => "dfh" + get :show, :url_name => "dfh", :view => 'all' response.should be_success end it "should render with 'show' template" do - get :show, :url_name => "dfh" + get :show, :url_name => "dfh", :view => 'all' response.should render_template('show') end it "should assign the body" do - get :show, :url_name => "dfh" + get :show, :url_name => "dfh", :view => 'all' assigns[:public_body].should == public_bodies(:humpadink_public_body) end + it "should assign the requests" do + get :show, :url_name => "tgq", :view => 'all' + assigns[:xapian_requests].results.count.should == 2 + get :show, :url_name => "tgq", :view => 'successful' + assigns[:xapian_requests].results.count.should == 0 + end + it "should assign the body using different locale from that used for url_name" do PublicBody.with_locale(:es) do - get :show, {:url_name => "dfh"} + get :show, {:url_name => "dfh", :view => 'all'} assigns[:public_body].notes.should == "Baguette" end end it "should assign the body using same locale as that used in url_name" do PublicBody.with_locale(:es) do - get :show, {:url_name => "edfh"} + get :show, {:url_name => "edfh", :view => 'all'} assigns[:public_body].notes.should == "Baguette" end end it "should redirect use to the relevant locale even when url_name is for a different locale" do ActionController::Routing::Routes.filters.clear - get :show, {:url_name => "edfh"} + get :show, {:url_name => "edfh", :view => 'all'} response.should redirect_to "http://test.host/body/dfh" end it "should redirect to newest name if you use historic name of public body in URL" do - get :show, :url_name => "hdink" + get :show, :url_name => "hdink", :view => 'all' response.should redirect_to(:controller => 'public_body', :action => 'show', :url_name => "dfh") end it "should redirect to lower case name if you use mixed case name in URL" do - get :show, :url_name => "dFh" + get :show, :url_name => "dFh", :view => 'all' response.should redirect_to(:controller => 'public_body', :action => 'show', :url_name => "dfh") end end @@ -128,7 +135,7 @@ describe PublicBodyController, "when showing JSON version for API" do fixtures :public_bodies, :public_body_translations it "should be successful" do - get :show, :url_name => "dfh", :format => "json" + get :show, :url_name => "dfh", :format => "json", :view => 'all' pb = JSON.parse(response.body) pb.class.to_s.should == 'Hash' |