aboutsummaryrefslogtreecommitdiffstats
path: root/railties/test/initializer/initialize_i18n_test.rb
blob: f952d06f94f14094af84596439ff1c98f0e018f9 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
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
      Rails::Initializer.run do |c|
        c.i18n.load_path << "my/other/locale.yml"
      end
      Rails.application.new

      #{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
      ), I18n.load_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.i18n.load_path << "my/other/locale.yml"
      end
      Rails.application.new

      #{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
      ), I18n.load_path
    end
  end
end