Module: TestProf::BeforeAll::Adapters::ActiveRecord
- Defined in:
- lib/test_prof/before_all/adapters/active_record.rb
Overview
ActiveRecord adapter for ‘before_all`
Class Method Summary collapse
Class Method Details
.begin_transaction ⇒ Object
9 10 11 |
# File 'lib/test_prof/before_all/adapters/active_record.rb', line 9 def begin_transaction ::ActiveRecord::Base.connection.begin_transaction(joinable: false) end |
.rollback_transaction ⇒ Object
13 14 15 16 17 18 19 20 |
# File 'lib/test_prof/before_all/adapters/active_record.rb', line 13 def rollback_transaction if ::ActiveRecord::Base.connection.open_transactions.zero? warn "!!! before_all transaction has been already rollbacked and " \ "could work incorrectly" return end ::ActiveRecord::Base.connection.rollback_transaction end |
.setup_fixtures(test_object) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/test_prof/before_all/adapters/active_record.rb', line 22 def setup_fixtures(test_object) test_object.instance_eval do @@already_loaded_fixtures ||= {} @fixture_cache ||= {} config = ::ActiveRecord::Base if @@already_loaded_fixtures[self.class] @loaded_fixtures = @@already_loaded_fixtures[self.class] else @loaded_fixtures = load_fixtures(config) @@already_loaded_fixtures[self.class] = @loaded_fixtures end end end |