diff options
Diffstat (limited to 'railties/test/application')
-rw-r--r-- | railties/test/application/rake_test.rb | 22 | ||||
-rw-r--r-- | railties/test/application/runner_test.rb | 10 |
2 files changed, 32 insertions, 0 deletions
diff --git a/railties/test/application/rake_test.rb b/railties/test/application/rake_test.rb index 107b54c0be..767a60f097 100644 --- a/railties/test/application/rake_test.rb +++ b/railties/test/application/rake_test.rb @@ -174,5 +174,27 @@ module ApplicationTests end end end + + def test_load_activerecord_base_when_we_use_observers + Dir.chdir(app_path) do + `bundle exec rails g model user; + bundle exec rake db:migrate; + bundle exec rails g observer user;` + + add_to_config "config.active_record.observers = :user_observer" + + assert_equal "0", `bundle exec rails r "puts User.count"`.strip + + app_file "lib/tasks/count_user.rake", <<-RUBY + namespace :user do + task :count => :environment do + puts User.count + end + end + RUBY + + assert_equal "0", `bundle exec rake user:count`.strip + end + end end end diff --git a/railties/test/application/runner_test.rb b/railties/test/application/runner_test.rb index 4468fa295e..d086f13c82 100644 --- a/railties/test/application/runner_test.rb +++ b/railties/test/application/runner_test.rb @@ -57,5 +57,15 @@ module ApplicationTests assert_match "script/program_name.rb", Dir.chdir(app_path) { `bundle exec rails runner "script/program_name.rb"` } end + + def test_with_hook + add_to_config <<-RUBY + runner do |app| + app.config.ran = true + end + RUBY + + assert_match "true", Dir.chdir(app_path) { `bundle exec rails runner "puts Rails.application.config.ran"` } + end end end |