aboutsummaryrefslogtreecommitdiffstats
path: root/railties/test/initializer
diff options
context:
space:
mode:
Diffstat (limited to 'railties/test/initializer')
-rw-r--r--railties/test/initializer/initialize_i18n_test.rb55
-rw-r--r--railties/test/initializer/path_test.rb23
2 files changed, 9 insertions, 69 deletions
diff --git a/railties/test/initializer/initialize_i18n_test.rb b/railties/test/initializer/initialize_i18n_test.rb
deleted file mode 100644
index 472566378d..0000000000
--- a/railties/test/initializer/initialize_i18n_test.rb
+++ /dev/null
@@ -1,55 +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/initializer/path_test.rb b/railties/test/initializer/path_test.rb
index 328dda6d2c..7a40d7fa6e 100644
--- a/railties/test/initializer/path_test.rb
+++ b/railties/test/initializer/path_test.rb
@@ -8,6 +8,7 @@ module InitializerTests
build_app
boot_rails
FileUtils.rm_rf("#{app_path}/config/environments")
+ app_file "config/environments/development.rb", ""
add_to_config <<-RUBY
config.root = "#{app_path}"
config.after_initialize do
@@ -36,19 +37,17 @@ module InitializerTests
end
test "booting up Rails yields a valid paths object" do
- assert_path @paths.app, "app"
assert_path @paths.app.metals, "app", "metal"
- assert_path @paths.app.models, "app", "models"
assert_path @paths.app.helpers, "app", "helpers"
- assert_path @paths.app.services, "app", "services"
+ assert_path @paths.app.views, "app", "views"
assert_path @paths.lib, "lib"
assert_path @paths.vendor, "vendor"
assert_path @paths.vendor.plugins, "vendor", "plugins"
assert_path @paths.tmp, "tmp"
assert_path @paths.tmp.cache, "tmp", "cache"
assert_path @paths.config, "config"
- assert_path @paths.config.locales, "config", "locales"
- assert_path @paths.config.environments, "config", "environments"
+ assert_path @paths.config.locales, "config", "locales", "en.yml"
+ assert_path @paths.config.environment, "config", "environments", "development.rb"
assert_equal root("app", "controllers"), @paths.app.controllers.to_a.first
assert_equal Pathname.new(File.dirname(__FILE__)).join("..", "..", "builtin", "rails_info").expand_path,
@@ -56,27 +55,23 @@ module InitializerTests
end
test "booting up Rails yields a list of paths that are eager" do
- assert @paths.app.models.eager_load?
+ assert @paths.app.eager_load?
assert @paths.app.controllers.eager_load?
assert @paths.app.helpers.eager_load?
- assert @paths.app.metals.eager_load?
end
test "environments has a glob equal to the current environment" do
- assert_equal "#{Rails.env}.rb", @paths.config.environments.glob
+ assert_equal "#{Rails.env}.rb", @paths.config.environment.glob
end
test "load path includes each of the paths in config.paths as long as the directories exist" do
- assert_in_load_path "app"
assert_in_load_path "app", "controllers"
assert_in_load_path "app", "models"
assert_in_load_path "app", "helpers"
assert_in_load_path "lib"
assert_in_load_path "vendor"
- assert_not_in_load_path "app", "views"
assert_not_in_load_path "app", "metal"
- assert_not_in_load_path "app", "services"
assert_not_in_load_path "config"
assert_not_in_load_path "config", "locales"
assert_not_in_load_path "config", "environments"
@@ -86,17 +81,17 @@ module InitializerTests
test "controller paths include builtin in development mode" do
Rails.env.replace "development"
- assert Rails::Configuration.new.paths.app.controllers.paths.any? { |p| p =~ /builtin/ }
+ assert Rails::Application::Configuration.new("/").paths.app.controllers.paths.any? { |p| p =~ /builtin/ }
end
test "controller paths does not have builtin_directories in test mode" do
Rails.env.replace "test"
- assert !Rails::Configuration.new.paths.app.controllers.paths.any? { |p| p =~ /builtin/ }
+ assert !Rails::Application::Configuration.new("/").paths.app.controllers.paths.any? { |p| p =~ /builtin/ }
end
test "controller paths does not have builtin_directories in production mode" do
Rails.env.replace "production"
- assert !Rails::Configuration.new.paths.app.controllers.paths.any? { |p| p =~ /builtin/ }
+ assert !Rails::Application::Configuration.new("/").paths.app.controllers.paths.any? { |p| p =~ /builtin/ }
end
end