From 7cccfed5943cddd6d72ed0df0ee7291cca9025ad Mon Sep 17 00:00:00 2001 From: Piotr Sarnacki Date: Sun, 18 Jul 2010 23:23:54 +0200 Subject: Allow Engines loading its own environment file from config/environments --- railties/test/application/loading_test.rb | 17 +++++++++++++++++ railties/test/railties/engine_test.rb | 29 +++++++++++++++++++++-------- 2 files changed, 38 insertions(+), 8 deletions(-) (limited to 'railties/test') diff --git a/railties/test/application/loading_test.rb b/railties/test/application/loading_test.rb index ecf7904c39..7ea712d27a 100644 --- a/railties/test/application/loading_test.rb +++ b/railties/test/application/loading_test.rb @@ -42,6 +42,23 @@ class LoadingTest < Test::Unit::TestCase User end + test "load config/environments/environment before Bootstrap initializers" do + app_file "config/environments/development.rb", <<-RUBY + AppTemplate::Application.configure do + config.development_environment_loaded = true + end + RUBY + + add_to_config <<-RUBY + config.before_initialize do + config.loaded = config.development_environment_loaded + end + RUBY + + require "#{app_path}/config/environment" + assert ::AppTemplate::Application.config.loaded + end + def test_descendants_are_cleaned_on_each_request_without_cache_classes add_to_config <<-RUBY config.cache_classes = false diff --git a/railties/test/railties/engine_test.rb b/railties/test/railties/engine_test.rb index 980265d969..09f2b5baa0 100644 --- a/railties/test/railties/engine_test.rb +++ b/railties/test/railties/engine_test.rb @@ -54,15 +54,9 @@ module RailtiesTest initializers = Rails.application.initializers.tsort index = initializers.index { |i| i.name == "dummy_initializer" } - selection = initializers[(index-3)..(index)].map(&:name).map(&:to_s) - - assert_equal %w( - load_config_initializers - load_config_initializers - engines_blank_point - dummy_initializer - ), selection + assert index > initializers.index { |i| i.name == :load_config_initializers } + assert index > initializers.index { |i| i.name == :engines_blank_point } assert index < initializers.index { |i| i.name == :build_middleware_stack } end @@ -164,5 +158,24 @@ module RailtiesTest assert !Bukkits::Engine.config.respond_to?(:engine_yaffle_loaded) assert Rails.application.config.app_yaffle_loaded end + + test "it loads its environment file" do + @plugin.write "lib/bukkits.rb", <<-RUBY + class Bukkits + class Engine < ::Rails::Engine + end + end + RUBY + + @plugin.write "config/environments/development.rb", <<-RUBY + Bukkits::Engine.configure do + config.environment_loaded = true + end + RUBY + + boot_rails + + assert Bukkits::Engine.config.environment_loaded + end end end -- cgit v1.2.3