Skip to content
Browse files

update for edge rails with hack so ActiveRecord::Base.connection.incr…

…ement_open_transactions still works in older versions of rails
  • Loading branch information...
1 parent b52c68c commit 6bc00b4b2be8d827c78bfa178dfbc3a8feacfbd4 @technoweenie committed
Showing with 11 additions and 1 deletion.
  1. +10 −0 init.rb
  2. +1 −1 lib/model_stubbing/definition.rb
View
10 init.rb
@@ -0,0 +1,10 @@
+# hack for rails 2.1 and below
+config.after_initialize do
+ unless ActiveRecord::Base.connection.respond_to?(:increment_open_transactions)
+ class << ActiveRecord::Base.connection
+ def increment_open_transactions
+ ActiveRecord::Base.send(:increment_open_transactions)
+ end
+ end
+ end
+end
View
2 lib/model_stubbing/definition.rb
@@ -115,7 +115,7 @@ def setup_test_run
ModelStubbing.records.clear
ModelStubbing.stub_current_time_with(current_time) if current_time
return unless database?
- ActiveRecord::Base.send :increment_open_transactions
+ ActiveRecord::Base.connection.increment_open_transactions
ActiveRecord::Base.connection.begin_db_transaction
end

0 comments on commit 6bc00b4

Please sign in to comment.
Something went wrong with that request. Please try again.