diff options
Diffstat (limited to 'spec/integration')
-rw-r--r-- | spec/integration/errors_spec.rb | 45 | ||||
-rw-r--r-- | spec/integration/search_request_spec.rb | 54 |
2 files changed, 99 insertions, 0 deletions
diff --git a/spec/integration/errors_spec.rb b/spec/integration/errors_spec.rb new file mode 100644 index 000000000..c64ca79e8 --- /dev/null +++ b/spec/integration/errors_spec.rb @@ -0,0 +1,45 @@ +require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') + +describe "When rendering errors" do + + fixtures [ :info_requests, + :info_request_events, + :public_bodies, + :public_body_translations, + :users, + :raw_emails, + :outgoing_messages, + :incoming_messages, + :comments ] + + before(:each) do + load_raw_emails_data(raw_emails) + ActionController::Base.consider_all_requests_local = false + end + + after(:each) do + ActionController::Base.consider_all_requests_local = true + end + + it "should render a 404 for unrouteable URLs" do + get("/frobsnasm") + response.code.should == "404" + response.body.should include("The page doesn't exist") + end + it "should render a 404 for users that don't exist" do + get("/user/wobsnasm") + response.code.should == "404" + end + it "should render a 404 for bodies that don't exist" do + get("/body/wobsnasm") + response.code.should == "404" + end + it "should render a 500 for general errors" do + ir = info_requests(:naughty_chicken_request) + # Set an invalid state for the request. Note that update_attribute doesn't run the validations + ir.update_attribute(:described_state, "crotchety") + get("/request/#{ir.url_title}") + response.code.should == "500" + end +end + diff --git a/spec/integration/search_request_spec.rb b/spec/integration/search_request_spec.rb index 9398519b7..dcd20c7bd 100644 --- a/spec/integration/search_request_spec.rb +++ b/spec/integration/search_request_spec.rb @@ -1,9 +1,63 @@ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') describe "When searching" do + + fixtures [ :info_requests, + :info_request_events, + :public_bodies, + :public_body_translations, + :users, + :raw_emails, + :outgoing_messages, + :incoming_messages, + :comments ] + + before(:each) do + emails = raw_emails.clone + load_raw_emails_data(emails) + end + it "should not strip quotes from quoted query" do request_via_redirect("post", "/search", :query => '"mouse stilton"') response.body.should include(""mouse stilton"") end + + it "should correctly execute simple search" do + request_via_redirect("post", "/search", + :query => 'bob' + ) + response.body.should include("FOI requests") + end + + it "should correctly filter searches for requests" do + request_via_redirect("post", "/search/bob/requests") + response.body.should_not include("One person found") + response.body.should include("FOI requests 1 to 2 of 2") + end + it "should correctly filter searches for users" do + request_via_redirect("post", "/search/bob/users") + response.body.should include("One person found") + response.body.should_not include("FOI requests 1 to 2 of 2") + end + + it "should correctly filter searches for successful requests" do + request_via_redirect("post", "/search", + :query => "bob", + :latest_status => ['successful']) + response.body.should include("no requests matching your query") + end + + it "should correctly filter searches for comments" do + request_via_redirect("post", "/search", + :query => "daftest", + :request_variety => ['comments']) + response.body.should include("One FOI request found") + + request_via_redirect("post", "/search", + :query => "daftest", + :request_variety => ['response','sent']) + response.body.should include("no requests matching your query") + end + end |