diff options
author | José Valim <jose.valim@gmail.com> | 2012-05-29 08:48:00 -0700 |
---|---|---|
committer | José Valim <jose.valim@gmail.com> | 2012-05-29 08:48:00 -0700 |
commit | 9fa3926e4fd1c3c24a9ecc613b98cde6609f2975 (patch) | |
tree | 8333b39bc6618a209c462a53c7286f8a5bcf0da5 /railties/test/application | |
parent | d46a36805b93478f39039f4cab006f0aabd4cfd0 (diff) | |
parent | c0ba0f01d05844bf3024d3926900706b270adf4d (diff) | |
download | rails-9fa3926e4fd1c3c24a9ecc613b98cde6609f2975.tar.gz rails-9fa3926e4fd1c3c24a9ecc613b98cde6609f2975.tar.bz2 rails-9fa3926e4fd1c3c24a9ecc613b98cde6609f2975.zip |
Merge pull request #6518 from kennyj/fix_5847-4
(Try again) Fix #5847 and #4045.
Diffstat (limited to 'railties/test/application')
-rw-r--r-- | railties/test/application/rake_test.rb | 23 | ||||
-rw-r--r-- | railties/test/application/runner_test.rb | 10 |
2 files changed, 33 insertions, 0 deletions
diff --git a/railties/test/application/rake_test.rb b/railties/test/application/rake_test.rb index 27d521485c..8cf867da3c 100644 --- a/railties/test/application/rake_test.rb +++ b/railties/test/application/rake_test.rb @@ -167,5 +167,28 @@ module ApplicationTests end assert !File.exists?(File.join(app_path, 'db', 'schema_cache.dump')) 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 e1d283a7fd..81ed5873a5 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 |