Skip to content

Commit

Permalink
testr/config/rails: retain in-memory-DB connection
Browse files Browse the repository at this point in the history
  • Loading branch information
sunaku committed Jan 20, 2012
1 parent 6771309 commit e57ecc6
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/testr/config/rails.rb
Expand Up @@ -22,7 +22,9 @@
end

TestR::Config.after_fork_hooks << proc do
ActiveRecord::Base.connection.reconnect!
unless ActiveRecord::Base.connection_config[:database] == ':memory:'
ActiveRecord::Base.connection.reconnect!
end
end

begin
Expand Down

2 comments on commit e57ecc6

@bquorning
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.connection_config is a Rails 3 method. For Rails 2 compatibility, you can use .connection_pool.spec.config

Also, shouldn鈥檛 you require 'active_record' at the top of the file?

@sunaku
Copy link
Owner Author

@sunaku sunaku commented on e57ecc6 Jan 25, 2012

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, fixed in b8e5e0a. I didn't require AR because I assumed it would be loaded by the test execution overhead. Both approaches would have failed for people who use Rails without AR.

Please sign in to comment.