module TestProf::BeforeAll::Adapters::ActiveRecord

ActiveRecord adapter for `before_all`

Public Class Methods

begin_transaction() click to toggle source
# 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() click to toggle source
# 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) click to toggle source
# 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