Module: Rspec::Rails23::TransactionalDatabaseSupport::InstanceMethods
- Defined in:
- lib/rspec/rails23/transactional_database_support.rb
Instance Method Summary collapse
- #active_record_configured? ⇒ Boolean
- #transactional_protection_cleanup ⇒ Object
- #transactional_protection_start ⇒ Object
Instance Method Details
#active_record_configured? ⇒ Boolean
7 8 9 |
# File 'lib/rspec/rails23/transactional_database_support.rb', line 7 def active_record_configured? defined?(::ActiveRecord) && !::ActiveRecord::Base.configurations.blank? end |
#transactional_protection_cleanup ⇒ Object
18 19 20 21 22 23 24 25 26 27 |
# File 'lib/rspec/rails23/transactional_database_support.rb', line 18 def transactional_protection_cleanup return unless active_record_configured? if ::ActiveRecord::Base.connection.open_transactions != 0 ::ActiveRecord::Base.connection.rollback_db_transaction ::ActiveRecord::Base.connection.decrement_open_transactions end ::ActiveRecord::Base.clear_active_connections! end |
#transactional_protection_start ⇒ Object
11 12 13 14 15 16 |
# File 'lib/rspec/rails23/transactional_database_support.rb', line 11 def transactional_protection_start return unless active_record_configured? ::ActiveRecord::Base.connection.increment_open_transactions ::ActiveRecord::Base.connection.begin_db_transaction end |