From 9d8388c03d0faeaca29d233a340c58bd65f28a97 Mon Sep 17 00:00:00 2001 From: Seb Bacon Date: Tue, 30 Aug 2011 10:23:03 +0100 Subject: Distinguish between 404s and other errors. Fixes #161. --- spec/integration/errors_spec.rb | 61 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 spec/integration/errors_spec.rb (limited to 'spec/integration/errors_spec.rb') diff --git a/spec/integration/errors_spec.rb b/spec/integration/errors_spec.rb new file mode 100644 index 000000000..84a44c9c3 --- /dev/null +++ b/spec/integration/errors_spec.rb @@ -0,0 +1,61 @@ +require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') + +module TestCustomStates + def self.included(base) + base.extend(ClassMethods) + end + + module ClassMethods + def theme_extra_states + return ['crotchety'] + end + end +end + + +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) + InfoRequest.send(:include, TestCustomStates) + InfoRequest.class_eval('@@custom_states_loaded = true') + ir.set_described_state("crotchety") + ir.save! + InfoRequest.class_eval('@@custom_states_loaded = false') + get("/request/#{ir.url_title}") + response.code.should == "500" + end +end + -- cgit v1.2.3 From 7ad1ac47482d9ae5f89f80c89c83efcd0448ce3f Mon Sep 17 00:00:00 2001 From: David Cabo Date: Sat, 3 Sep 2011 16:49:57 +0200 Subject: Fix integration test breaking custom states spec --- spec/integration/errors_spec.rb | 20 ++------------------ 1 file changed, 2 insertions(+), 18 deletions(-) (limited to 'spec/integration/errors_spec.rb') diff --git a/spec/integration/errors_spec.rb b/spec/integration/errors_spec.rb index 84a44c9c3..c64ca79e8 100644 --- a/spec/integration/errors_spec.rb +++ b/spec/integration/errors_spec.rb @@ -1,18 +1,5 @@ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') -module TestCustomStates - def self.included(base) - base.extend(ClassMethods) - end - - module ClassMethods - def theme_extra_states - return ['crotchety'] - end - end -end - - describe "When rendering errors" do fixtures [ :info_requests, @@ -49,11 +36,8 @@ describe "When rendering errors" do end it "should render a 500 for general errors" do ir = info_requests(:naughty_chicken_request) - InfoRequest.send(:include, TestCustomStates) - InfoRequest.class_eval('@@custom_states_loaded = true') - ir.set_described_state("crotchety") - ir.save! - InfoRequest.class_eval('@@custom_states_loaded = false') + # 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 -- cgit v1.2.3