diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2014-11-04 15:00:56 -0800 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2014-11-04 15:00:56 -0800 |
commit | ffb6d37c04d7a97be612edc0cb9ffac69171c269 (patch) | |
tree | 5705e45db12dde1600a5f822c91e54a10b1a16c4 /railties/test | |
parent | 502c45a3428b3ce1a9892986d1bba5f8f975fb6d (diff) | |
parent | 9dbcac78113808da23dfe1e3e7b0cc6a390e03be (diff) | |
download | rails-ffb6d37c04d7a97be612edc0cb9ffac69171c269.tar.gz rails-ffb6d37c04d7a97be612edc0cb9ffac69171c269.tar.bz2 rails-ffb6d37c04d7a97be612edc0cb9ffac69171c269.zip |
Merge branch '17106'
* 17106:
add lib to $LOAD_PATH on application inhertence. fixes #17106
add a test for #17106
Diffstat (limited to 'railties/test')
-rw-r--r-- | railties/test/application/configuration_test.rb | 14 | ||||
-rw-r--r-- | railties/test/isolation/abstract_unit.rb | 9 |
2 files changed, 23 insertions, 0 deletions
diff --git a/railties/test/application/configuration_test.rb b/railties/test/application/configuration_test.rb index 0eddf644d9..2b6eb3624a 100644 --- a/railties/test/application/configuration_test.rb +++ b/railties/test/application/configuration_test.rb @@ -59,6 +59,20 @@ module ApplicationTests end end + test "lib dir is on LOAD_PATH during config" do + app_file 'lib/my_logger.rb', <<-RUBY + require "logger" + class MyLogger < ::Logger + end + RUBY + add_to_top_of_config <<-RUBY + require 'my_logger' + config.logger = MyLogger.new STDOUT + RUBY + require "#{app_path}/config/environment" + assert_equal 'MyLogger', Rails.application.config.logger.class.name + end + test "a renders exception on pending migration" do add_to_config <<-RUBY config.active_record.migration_error = :page_load diff --git a/railties/test/isolation/abstract_unit.rb b/railties/test/isolation/abstract_unit.rb index 40469e31d7..bf2992005b 100644 --- a/railties/test/isolation/abstract_unit.rb +++ b/railties/test/isolation/abstract_unit.rb @@ -231,6 +231,15 @@ module TestHelpers end end + def add_to_top_of_config(str) + environment = File.read("#{app_path}/config/application.rb") + if environment =~ /(Rails::Application\s*)/ + File.open("#{app_path}/config/application.rb", 'w') do |f| + f.puts $` + $1 + "\n#{str}\n" + $' + end + end + end + def add_to_config(str) environment = File.read("#{app_path}/config/application.rb") if environment =~ /(\n\s*end\s*end\s*)\Z/ |