lib/after_commit.rb in larsklevan-after_commit-1.0.5 vs lib/after_commit.rb in larsklevan-after_commit-1.0.6
- old
+ new
@@ -16,11 +16,11 @@
def self.record_destroyed(connection, record)
prepare_collection :committed_records_on_destroy, connection
add_to_collection :committed_records_on_destroy, connection, record
end
-
+
def self.records(connection)
collection :committed_records, connection
end
def self.created_records(connection)
@@ -40,36 +40,36 @@
:committed_records,
:committed_records_on_create,
:committed_records_on_update,
:committed_records_on_destroy
].each do |collection|
- Thread.current[collection] ||= {}
- Thread.current[collection][connection.old_transaction_key] = []
+ Thread.current[collection] ||= {}
+ Thread.current[collection][connection.previous_transaction_key] = []
end
end
-
+
def self.prepare_collection(collection, connection)
Thread.current[collection] ||= {}
- Thread.current[collection][connection.unique_transaction_key] ||= []
+ Thread.current[collection][connection.current_transaction_key] ||= []
end
-
+
def self.add_to_collection(collection, connection, record)
- Thread.current[collection][connection.unique_transaction_key] << record
+ Thread.current[collection][connection.current_transaction_key] << record
end
-
+
def self.collection(collection, connection)
Thread.current[collection] ||= {}
- Thread.current[collection][connection.old_transaction_key] ||= []
+ Thread.current[collection][connection.previous_transaction_key] ||= []
end
end
require 'after_commit/active_record'
require 'after_commit/connection_adapters'
require 'after_commit/after_savepoint'
ActiveRecord::Base.send(:include, AfterCommit::ActiveRecord)
ActiveRecord::Base.include_after_commit_extensions
-if defined?(RAILS_ENV) && RAILS_ENV == 'test'
+if defined?(RAILS_ENV) && %w(test cucumber).include?(RAILS_ENV)
ActiveRecord::Base.send(:include, AfterCommit::AfterSavepoint)
ActiveRecord::Base.include_after_savepoint_extensions
end
\ No newline at end of file