diff options
Diffstat (limited to 'spec')
-rw-r--r-- | spec/controllers/request_controller_spec.rb | 12 | ||||
-rw-r--r-- | spec/integration/errors_spec.rb | 61 |
2 files changed, 66 insertions, 7 deletions
diff --git a/spec/controllers/request_controller_spec.rb b/spec/controllers/request_controller_spec.rb index 2b153ac7a..f3084af12 100644 --- a/spec/controllers/request_controller_spec.rb +++ b/spec/controllers/request_controller_spec.rb @@ -161,7 +161,7 @@ describe RequestController, "when showing one request" do lambda { get :get_attachment, :incoming_message_id => ir.incoming_messages[1].id, :id => ir.id, :part => 2, :file_name => ['http://trying.to.hack'] - }.should raise_error(RuntimeError) + }.should raise_error(ActiveRecord::RecordNotFound) end it "should censor attachments downloaded as binary" do @@ -747,18 +747,16 @@ describe RequestController, "when classifying an information request" do response.should redirect_to(:controller => 'help', :action => 'unhappy', :url_title => @dog_request.url_title) end - describe "when using custom statuses from the theme" do + it "knows about extended states" do InfoRequest.send(:require, File.expand_path(File.join(File.dirname(__FILE__), '..', 'models', 'customstates'))) InfoRequest.send(:include, InfoRequestCustomStates) InfoRequest.class_eval('@@custom_states_loaded = true') RequestController.send(:require, File.expand_path(File.join(File.dirname(__FILE__), '..', 'models', 'customstates'))) RequestController.send(:include, RequestControllerCustomStates) RequestController.class_eval('@@custom_states_loaded = true') - it "knows about extended states" do - Time.stub!(:now).and_return(Time.utc(2007, 11, 10, 00, 01)) - post_status('deadline_extended') - flash[:notice].should == 'Authority has requested extension of the deadline.' - end + Time.stub!(:now).and_return(Time.utc(2007, 11, 10, 00, 01)) + post_status('deadline_extended') + flash[:notice].should == 'Authority has requested extension of the deadline.' end end 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 + |