From 021137133cd6f496b83278c2eebb558223843b7f Mon Sep 17 00:00:00 2001 From: Robin Houston Date: Wed, 1 Aug 2012 11:28:03 +0100 Subject: Set locale even for errors The locale was not being set correctly for error pages, causing some order-dependent test failures, e.g.: script/spec spec/controllers/services_controller_spec.rb spec/integration/errors_spec.rb was failing. Many many many thanks to Louise Crow for tracking this one down! --- app/controllers/application_controller.rb | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'app/controllers/application_controller.rb') diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 11f21025c..a124743b2 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -134,6 +134,10 @@ class ApplicationController < ActionController::Base # Make sure expiry time for session is set (before_filters are # otherwise missed by this override) session_remember_me + + # Make sure the locale is set correctly too + set_gettext_locale + case exception when ActiveRecord::RecordNotFound, ActionController::UnknownAction, ActionController::RoutingError @status = 404 @@ -157,6 +161,9 @@ class ApplicationController < ActionController::Base # otherwise missed by this override) session_remember_me + # Make sure the locale is set correctly too + set_gettext_locale + # Display default, detailed error for developers original_rescue_action_locally(exception) end -- cgit v1.2.3 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. --- app/controllers/application_controller.rb | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'app/controllers/application_controller.rb') diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 7b5eb5590..ce18e6ef5 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -134,10 +134,10 @@ class ApplicationController < ActionController::Base # Make sure expiry time for session is set (before_filters are # otherwise missed by this override) session_remember_me - + # Make sure the locale is set correctly too set_gettext_locale - + case exception when ActiveRecord::RecordNotFound, ActionController::UnknownAction, ActionController::RoutingError @status = 404 @@ -392,8 +392,11 @@ class ApplicationController < ActionController::Base # might fail later if the database has subsequently been reopened. return result end + def get_search_page_from_params - return (params[:page] || "1").to_i + page = (params[:page] || "1").to_i + page = 1 if page < 1 + return page end def perform_search_typeahead(query, model) -- cgit v1.2.3