public
Rubygem
Description: RSpec extension library for Ruby on Rails
Homepage:
Clone URL: git://github.com/dchelimsky/rspec-rails.git
Move [increment|decrement]_open_transactions from ActiveRecord::Base to 
ActiveRecord::Base.connection (for edge > v2.1.0)"
David Chelimsky (author)
Thu Jul 17 21:09:25 -0700 2008
commit  96e2389b6162bf3ab87d78d06615f61a2778491f
tree    9af1bbb527dc702c26fa006e062cb679cd5bb916
parent  6499e4e0d26451c090d88c4312fa245c189979b1
...
40
41
42
43
 
 
 
 
 
44
45
46
...
48
49
50
51
 
 
 
 
 
52
53
54
...
40
41
42
 
43
44
45
46
47
48
49
50
...
52
53
54
 
55
56
57
58
59
60
61
62
0
@@ -40,7 +40,11 @@ class ActiveRecordSafetyListener
0
   include Singleton
0
   def scenario_started(*args)
0
     if defined?(ActiveRecord::Base)
0
-      ActiveRecord::Base.send :increment_open_transactions unless Rails::VERSION::STRING == "1.1.6"
0
+      if ActiveRecord::Base.respond_to?(:increment_open_transactions)
0
+        ActiveRecord::Base.send :increment_open_transactions
0
+      elsif ActiveRecord::Base.connection.respond_to?(:increment_open_transactions)
0
+        ActiveRecord::Base.connection.send :increment_open_transactions
0
+      end
0
       ActiveRecord::Base.connection.begin_db_transaction
0
     end
0
   end
0
@@ -48,7 +52,11 @@ class ActiveRecordSafetyListener
0
   def scenario_succeeded(*args)
0
     if defined?(ActiveRecord::Base)
0
       ActiveRecord::Base.connection.rollback_db_transaction
0
-      ActiveRecord::Base.send :decrement_open_transactions unless Rails::VERSION::STRING == "1.1.6"
0
+      if ActiveRecord::Base.respond_to?(:decrement_open_transactions)
0
+        ActiveRecord::Base.send :decrement_open_transactions
0
+      elsif ActiveRecord::Base.connection.respond_to?(:decrement_open_transactions)
0
+        ActiveRecord::Base.connection.send :decrement_open_transactions
0
+      end
0
     end
0
   end
0
   alias :scenario_pending :scenario_succeeded

Comments