Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6 from cawel/controller_helper
Functional tests support
- Loading branch information
Showing
2 changed files
with
30 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# This monkey patch injects the locale in the controller's params | ||
# Reason: ActionController::TestCase doesn't support "default_url_options" | ||
# | ||
# Example: when the request you are testing needs the locale, e.g. | ||
# get :show, :id => 1, :locale => 'en' | ||
# | ||
# if the monkey patch was loaded, you can just do: | ||
# get :show, :id => 1 | ||
|
||
class ActionController::TestCase | ||
|
||
module Behavior | ||
def process_with_default_locale(action, parameters = nil, session = nil, flash = nil, http_method = 'GET') | ||
parameters = { :locale => I18n.default_locale }.merge(parameters || {} ) | ||
process_without_default_locale(action, parameters, session, flash, http_method) | ||
end | ||
alias_method_chain :process, :default_locale | ||
end | ||
end |