Permalink
Find file
Fetching contributors…
Cannot retrieve contributors at this time
34 lines (29 sloc) 1.36 KB
# Author: Raul Murciano [http://raul.murciano.net] for Domestika [http://domestika.org]
# Copyright (c) 2007, Released under the MIT license (see MIT-LICENSE)
require 'rails/test_help'
# Include default lang on your test requests (test requests doesn't support default_url_options):
ActionController::TestCase.class_eval do
unless method_defined?(:process_without_default_language)
def process_with_default_language(action, parameters = nil, session = nil, flash = nil, http_method = 'GET')
lang_pair = {:locale, I18n.default_locale.to_s}
parameters = lang_pair.merge(parameters) rescue lang_pair
process_without_default_language(action, parameters, session, flash, http_method)
end
alias :process_without_default_language :process
alias :process :process_with_default_language
end
end
# Add untranslated helper for named routes to integration tests
ActionController::Integration::Session.class_eval do
['path', 'url'].each do |suffix|
ActionDispatch::Routing::Translator.original_names.each do |old_name|
new_helper_name = "#{old_name}_#{suffix}"
def_new_helper = <<-DEF_NEW_HELPER
def #{new_helper_name}(*args)
send("#{old_name}_#{ActionDispatch::Routing::Translator.locale_suffix(I18n.locale)}_#{suffix}", *args)
end
DEF_NEW_HELPER
eval def_new_helper
end
end
end