aboutsummaryrefslogtreecommitdiffstats
path: root/spec/integration/errors_spec.rb
diff options
context:
space:
mode:
authorGareth Rees <gareth@mysociety.org>2014-04-10 12:53:06 +0100
committerGareth Rees <gareth@mysociety.org>2014-04-10 12:53:06 +0100
commitb0fbe646f386b866791fbb321d6fa183bb4a6517 (patch)
treec2a694bd2137cbb7ceb019864014b7aff0b7ea7b /spec/integration/errors_spec.rb
parentd1f2d56834688c5b449ac8c50b67dff0672ca074 (diff)
Rescue from non-numeric page parameter exceptions
will_paginate intentionally throws an ArgumentError when a non-numeric page parameter is used. Conveniently, they tag it with WillPaginate::InvalidPage, so here we rescue with a 404.
Diffstat (limited to 'spec/integration/errors_spec.rb')
-rw-r--r--spec/integration/errors_spec.rb8
1 files changed, 8 insertions, 0 deletions
diff --git a/spec/integration/errors_spec.rb b/spec/integration/errors_spec.rb
index 3ff3edb53..8ceb8243b 100644
--- a/spec/integration/errors_spec.rb
+++ b/spec/integration/errors_spec.rb
@@ -54,6 +54,14 @@ describe "When errors occur" do
end
end
+ it 'should render a 404 when given an invalid page parameter' do
+ get '/body/list/all', :page => 'xoforvfmy'
+ response.should render_template('general/exception_caught')
+ response.code.should == '404'
+ response.body.should match("Sorry, we couldn't find that page")
+ response.body.should match(%Q(invalid value for Integer))
+ end
+
it 'should url encode params' do
get ('/%d3')
response.should render_template('general/exception_caught')