diff options
author | José Valim <jose.valim@gmail.com> | 2010-01-24 10:27:42 +0100 |
---|---|---|
committer | José Valim <jose.valim@gmail.com> | 2010-01-24 10:27:42 +0100 |
commit | 5cd9aad4fdf55c591fe8e12657008e83315251d7 (patch) | |
tree | eec14a886cde637359fc478064864a345be2be56 /railties | |
parent | 25724c664d8af6c50903709da69a5871475383fe (diff) | |
download | rails-5cd9aad4fdf55c591fe8e12657008e83315251d7.tar.gz rails-5cd9aad4fdf55c591fe8e12657008e83315251d7.tar.bz2 rails-5cd9aad4fdf55c591fe8e12657008e83315251d7.zip |
Add I18n tests to engines.
Diffstat (limited to 'railties')
-rw-r--r-- | railties/test/initializer/initialize_i18n_test.rb | 56 | ||||
-rw-r--r-- | railties/test/plugins/vendored_test.rb | 38 |
2 files changed, 38 insertions, 56 deletions
diff --git a/railties/test/initializer/initialize_i18n_test.rb b/railties/test/initializer/initialize_i18n_test.rb deleted file mode 100644 index 64396bddb4..0000000000 --- a/railties/test/initializer/initialize_i18n_test.rb +++ /dev/null @@ -1,56 +0,0 @@ -require "isolation/abstract_unit" - -module InitializerTests - class InitializeI18nTest < Test::Unit::TestCase - include ActiveSupport::Testing::Isolation - - def setup - build_app - boot_rails - end - - # test_config_defaults_and_settings_should_be_added_to_i18n_defaults - test "i18n config defaults and settings should be added to i18n defaults" do - add_to_config <<-RUBY - config.root = "#{app_path}" - config.i18n.load_path << "my/other/locale.yml" - RUBY - - require "#{app_path}/config/environment" - - #{RAILS_FRAMEWORK_ROOT}/railties/test/fixtures/plugins/engines/engine/config/locales/en.yml - assert_equal %W( - #{RAILS_FRAMEWORK_ROOT}/activesupport/lib/active_support/locale/en.yml - #{RAILS_FRAMEWORK_ROOT}/activemodel/lib/active_model/locale/en.yml - #{RAILS_FRAMEWORK_ROOT}/activerecord/lib/active_record/locale/en.yml - #{RAILS_FRAMEWORK_ROOT}/actionpack/lib/action_view/locale/en.yml - #{RAILS_FRAMEWORK_ROOT}/railties/tmp/app/config/locales/en.yml - my/other/locale.yml - ).map { |path| File.expand_path(path) }, I18n.load_path.map { |path| File.expand_path(path) } - end - - test "i18n finds locale files in engines" do - # app_file "vendor/plugins/engine/init.rb", "" - # app_file "vendor/plugins/engine/app/models/hellos.rb", "class Hello ; end" - # app_file "vendor/plugins/engine/lib/omg.rb", "puts 'omg'" - # app_file "vendor/plugins/engine/config/locales/en.yml", "hello:" - # - # Rails::Initializer.run do |c| - # c.root = app_path - # c.i18n.load_path << "my/other/locale.yml" - # end - # Rails.initialize! - # - # #{RAILS_FRAMEWORK_ROOT}/railties/test/fixtures/plugins/engines/engine/config/locales/en.yml - # assert_equal %W( - # #{RAILS_FRAMEWORK_ROOT}/activesupport/lib/active_support/locale/en.yml - # #{RAILS_FRAMEWORK_ROOT}/activemodel/lib/active_model/locale/en.yml - # #{RAILS_FRAMEWORK_ROOT}/activerecord/lib/active_record/locale/en.yml - # #{RAILS_FRAMEWORK_ROOT}/actionpack/lib/action_view/locale/en.yml - # #{app_path}/config/locales/en.yml - # my/other/locale.yml - # #{app_path}/vendor/plugins/engine/config/locales/en.yml - # ).map { |path| File.expand_path(path) }, I18n.load_path.map { |path| File.expand_path(path) } - end - end -end
\ No newline at end of file diff --git a/railties/test/plugins/vendored_test.rb b/railties/test/plugins/vendored_test.rb index eae73ee5d8..6207cd13c1 100644 --- a/railties/test/plugins/vendored_test.rb +++ b/railties/test/plugins/vendored_test.rb @@ -179,6 +179,44 @@ module PluginsTest Rake::Task[:foo].invoke assert $executed end + + test "i18n files are added with lower priority than application ones" do + add_to_config <<-RUBY + config.i18n.load_path << "#{app_path}/app/locales/en.yml" + RUBY + + app_file 'app/locales/en.yml', <<-YAML +en: + bar: "1" +YAML + + app_file 'config/locales/en.yml', <<-YAML +en: + foo: "2" + bar: "2" +YAML + + @plugin.write 'config/locales/en.yml', <<-YAML +en: + foo: "3" +YAML + + boot_rails + require "#{app_path}/config/environment" + + assert_equal %W( + #{RAILS_FRAMEWORK_ROOT}/activesupport/lib/active_support/locale/en.yml + #{RAILS_FRAMEWORK_ROOT}/activemodel/lib/active_model/locale/en.yml + #{RAILS_FRAMEWORK_ROOT}/activerecord/lib/active_record/locale/en.yml + #{RAILS_FRAMEWORK_ROOT}/actionpack/lib/action_view/locale/en.yml + #{app_path}/vendor/plugins/bukkits/config/locales/en.yml + #{app_path}/config/locales/en.yml + #{app_path}/app/locales/en.yml + ).map { |path| File.expand_path(path) }, I18n.load_path.map { |path| File.expand_path(path) } + + assert_equal "2", I18n.t(:foo) + assert_equal "1", I18n.t(:bar) + end end class VendoredOrderingTest < Test::Unit::TestCase |