diff options
Diffstat (limited to 'spec')
-rw-r--r-- | spec/controllers/general_controller_spec.rb | 2 | ||||
-rw-r--r-- | spec/controllers/public_body_controller_spec.rb | 25 | ||||
-rw-r--r-- | spec/controllers/request_controller_spec.rb | 6 | ||||
-rw-r--r-- | spec/views/public_body/show.rhtml_spec.rb | 5 |
4 files changed, 21 insertions, 17 deletions
diff --git a/spec/controllers/general_controller_spec.rb b/spec/controllers/general_controller_spec.rb index 3640a8148..a76cdd3b6 100644 --- a/spec/controllers/general_controller_spec.rb +++ b/spec/controllers/general_controller_spec.rb @@ -64,7 +64,7 @@ describe GeneralController, "when searching" do it "should redirect from search query URL to pretty URL" do post :search_redirect, :query => "mouse" # query hidden in POST parameters - response.should redirect_to(:action => 'search', :combined => "mouse") # URL /search/:query + response.should redirect_to(:action => 'search', :combined => "mouse", :view => "all") # URL /search/:query/all end describe "when using different locale settings" do 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' diff --git a/spec/controllers/request_controller_spec.rb b/spec/controllers/request_controller_spec.rb index f69cf414c..7d0cd2c1a 100644 --- a/spec/controllers/request_controller_spec.rb +++ b/spec/controllers/request_controller_spec.rb @@ -1,7 +1,3 @@ -# £2k p/a -# talk about margins -# - require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') require 'json' @@ -30,7 +26,7 @@ describe RequestController, "when listing recent requests" do :matches_estimated => 103) InfoRequest.should_receive(:full_search). - with([InfoRequestEvent],"variety:sent", "created_at", anything, anything, anything, anything). + with([InfoRequestEvent]," variety:sent", "created_at", anything, anything, anything, anything). and_return(xap_results) get :list, :view => 'recent' assigns[:list_results].size.should == 25 diff --git a/spec/views/public_body/show.rhtml_spec.rb b/spec/views/public_body/show.rhtml_spec.rb index 7793b9b38..f859b0679 100644 --- a/spec/views/public_body/show.rhtml_spec.rb +++ b/spec/views/public_body/show.rhtml_spec.rb @@ -1,7 +1,6 @@ require File.dirname(__FILE__) + '/../../spec_helper' describe "when viewing a body" do - before do @pb = mock_model(PublicBody, :name => 'Test Quango', @@ -28,6 +27,8 @@ describe "when viewing a body" do assigns[:xapian_requests] = @xap assigns[:page] = 1 assigns[:per_page] = 10 + # work round a bug in ActionController::TestRequest; allows request.query_string to work in the template + request.env["REQUEST_URI"] = "" end it "should be successful" do @@ -51,7 +52,7 @@ describe "when viewing a body" do end it "should cope with no results" do - @xap.stub!(:results).and_return([]) + @pb.stub!(:info_requests).and_return([]) render "public_body/show" response.should have_tag("p", /Nobody has made any Freedom of Information requests/m) end |