Created
March 2, 2012 04:16
-
-
Save nalanj/1955584 to your computer and use it in GitHub Desktop.
Config to force rails to clear connections in our base environment.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| TConsole::Config.run do |config| | |
| config.preload_paths = ["./config/application"] | |
| config.include_paths = ["./test"] | |
| config.file_sets = { | |
| "all" => ["#{config.test_dir}/unit/**/*_test.rb", "#{config.test_dir}/functional/**/*_test.rb", | |
| "#{config.test_dir}/integration/**/*_test.rb"], | |
| "units" => ["#{config.test_dir}/unit/**/*_test.rb"], | |
| "unit" => ["#{config.test_dir}/unit/**/*_test.rb"], | |
| "functionals" => ["#{config.test_dir}/functional/**/*_test.rb"], | |
| "functional" => ["#{config.test_dir}/functional/**/*_test.rb"], | |
| "integration" => ["#{config.test_dir}/integration/**/*_test.rb"] | |
| } | |
| config.before_load do | |
| ENV["RAILS_ENV"] ||= "test" | |
| end | |
| config.after_load do | |
| ::Rails.application | |
| ::Rails::Engine.class_eval do | |
| def eager_load! | |
| # turn off eager_loading | |
| end | |
| end | |
| if defined? ::ActiveRecord | |
| puts "Clearing ActiveRecord connection - just in case." | |
| ::ActiveRecord::Base.clear_active_connections! | |
| end | |
| end | |
| config.before_test_run do | |
| if defined? ::ActiveRecord | |
| ::ActiveRecord::Base.clear_active_connections! | |
| ::ActiveRecord::Base.establish_connection | |
| end | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment