Skip to content

Commit

Permalink
Add a testcase for GH rails#4045
Browse files Browse the repository at this point in the history
  • Loading branch information
kennyj committed Jan 4, 2012
1 parent 4a0eb3e commit 38c9618
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions railties/test/application/rake_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -138,5 +138,27 @@ def test_rake_dump_structure_should_respect_db_structure_env_variable
end
assert File.exists?(File.join(app_path, 'db', 'my_structure.sql'))
end

def test_model_loading_when_we_use_observers
Dir.chdir(app_path) do
`bundle exec rails generate model user`
`bundle exec rake db:migrate`
end
app_file "app/models/user_observer.rb", <<-RUBY
class UserObserver < ActiveRecord::Observer
end
RUBY
app_file "lib/tasks/count_user.rake", <<-RUBY
namespace :user do
task :count => :environment do
p User.count
end
end
RUBY
add_to_config "config.active_record.observers = :user_observer"

output = Dir.chdir(app_path) { `bundle exec rake user:count` }
assert_equal "0", output.strip
end
end
end

0 comments on commit 38c9618

Please sign in to comment.