Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Changeset 8159

Show
Ignore:
Timestamp:
11/17/07 01:38:58 (8 months ago)
Author:
bitsweat
Message:

Load config/preinitializer.rb, if present, before loading the environment. Closes #9943.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/railties/CHANGELOG

    r8132 r8159  
    11*SVN* 
     2 
     3* Load config/preinitializer.rb, if present, before loading the environment.  #9943 [Chad Woolley] 
    24 
    35* FastCGI handler ignores unsupported signals like USR2 on Windows.  [Grzegorz Derebecki] 
  • trunk/railties/environments/boot.rb

    r8021 r8159  
    77  class << self 
    88    def boot! 
    9       pick_boot.run unless booted? 
     9      unless booted? 
     10        preinitialize 
     11        pick_boot.run 
     12      end 
    1013    end 
    1114 
     
    2023    def vendor_rails? 
    2124      File.exist?("#{RAILS_ROOT}/vendor/rails") 
     25    end 
     26 
     27    def preinitialize 
     28      load(preinitializer_path) if File.exists?(preinitializer_path) 
     29    end 
     30 
     31    def preinitializer_path 
     32      "#{RAILS_ROOT}/config/preinitializer.rb" 
    2233    end 
    2334  end 
  • trunk/railties/test/boot_test.rb

    r7998 r8159  
    1212  end 
    1313 
    14   def test_boot_picks_and_runs_if_not_booted 
     14  def test_boot_preinitializes_then_picks_and_runs_if_not_booted 
    1515    Rails.expects(:booted?).returns(false) 
     16    Rails.expects(:preinitialize) 
    1617    Rails.expects(:pick_boot).returns(mock(:run => 'result')) 
    1718    assert_equal 'result', Rails.boot! 
     19  end 
     20 
     21  def test_preinitialize_does_not_raise_exception_if_preinitializer_file_does_not_exist 
     22    Rails.stubs(:preinitializer_path).returns('/there/is/no/such/file') 
     23 
     24    assert_nothing_raised { Rails.preinitialize } 
     25  end 
     26 
     27  def test_load_preinitializer_loads_preinitializer_file 
     28    Rails.stubs(:preinitializer_path).returns("#{File.dirname(__FILE__)}/fixtures/environment_with_constant.rb") 
     29 
     30    assert_nil $initialize_test_set_from_env 
     31    Rails.preinitialize 
     32    assert_equal "success", $initialize_test_set_from_env 
     33  ensure 
     34    $initialize_test_set_from_env = nil 
    1835  end 
    1936