From b8ed99e84120c561bfc9650144c26c5ccada4939 Mon Sep 17 00:00:00 2001 From: Louise Crow Date: Tue, 21 Aug 2012 10:59:48 +0100 Subject: Don't pass a page param of less than one through to Xapian, treat it as a param of 1. Fixes #557. --- spec/controllers/request_controller_spec.rb | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'spec/controllers/request_controller_spec.rb') diff --git a/spec/controllers/request_controller_spec.rb b/spec/controllers/request_controller_spec.rb index f91f87323..f7316a2c0 100644 --- a/spec/controllers/request_controller_spec.rb +++ b/spec/controllers/request_controller_spec.rb @@ -114,6 +114,7 @@ describe RequestController, "when listing recent requests" do assigns[:list_results].size.should == 25 assigns[:show_no_more_than].should == RequestController::MAX_RESULTS end + it "should return 404 for pages we don't want to serve up" do xap_results = mock_model(ActsAsXapian::Search, :results => (1..25).to_a.map { |m| { :model => m } }, @@ -123,6 +124,12 @@ describe RequestController, "when listing recent requests" do }.should raise_error(ActiveRecord::RecordNotFound) end + it 'should not raise an error for a page param of less than zero, but should treat it as + a param of 1' do + lambda{ get :list, :view => 'all', :page => "-1" }.should_not raise_error + assigns[:page].should == 1 + end + end describe RequestController, "when changing things that appear on the request page" do @@ -1890,7 +1897,7 @@ describe RequestController, "when reporting a request (logged in)" do @user = users(:robin_user) session[:user_id] = @user.id end - + it "should 404 for non-existent requests" do lambda { post :report_request, :url_title => "hjksfdhjk_louytu_qqxxx" -- cgit v1.2.3