diff options
author | Saimon Moore <saimon@saimonmoore.net> | 2011-01-28 13:53:07 +0100 |
---|---|---|
committer | Santiago Pastorino <santiago@wyeworks.com> | 2011-02-01 15:35:48 -0200 |
commit | b1ca339b53559a71958c02644e329c714037f616 (patch) | |
tree | 0234f83ff3d3a7dd422635ceaab6b0368716b84c /railties/test | |
parent | cb9fa5283239e649483ea31ca372e99aaac2ca07 (diff) | |
download | rails-b1ca339b53559a71958c02644e329c714037f616.tar.gz rails-b1ca339b53559a71958c02644e329c714037f616.tar.bz2 rails-b1ca339b53559a71958c02644e329c714037f616.zip |
Additionally trigger i18n configuration setup before any eager loading [#6353 state:resolved]
This handles the case where config.cache_classes is true and classes
are loaded before the I18n load path has had a chance to be populated.
Signed-off-by: Santiago Pastorino <santiago@wyeworks.com>
Diffstat (limited to 'railties/test')
-rw-r--r-- | railties/test/application/initializers/i18n_test.rb | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/railties/test/application/initializers/i18n_test.rb b/railties/test/application/initializers/i18n_test.rb index 178b31cff3..390f65ab5c 100644 --- a/railties/test/application/initializers/i18n_test.rb +++ b/railties/test/application/initializers/i18n_test.rb @@ -63,6 +63,36 @@ module ApplicationTests assert I18n.load_path.include?("#{app_path}/config/another_locale.yml") end + test "load_path is populated before eager loaded models" do + add_to_config <<-RUBY + config.cache_classes = true + RUBY + + app_file "config/locales/en.yml", <<-YAML +en: + foo: "1" + YAML + + app_file 'app/models/foo.rb', <<-RUBY + class Foo < ActiveRecord::Base + @foo = I18n.t(:foo) + end + RUBY + + app_file 'config/routes.rb', <<-RUBY + AppTemplate::Application.routes.draw do + match '/i18n', :to => lambda { |env| [200, {}, [Foo.instance_variable_get('@foo')]] } + end + RUBY + + require 'rack/test' + extend Rack::Test::Methods + load_app + + get "/i18n" + assert_equal "1", last_response.body + end + test "locales are reloaded if they change between requests" do add_to_config <<-RUBY config.cache_classes = false |