Module: ActiveRecord::Tenanted::Testing::ActiveRecordFixtures
- Defined in:
- lib/active_record/tenanted/testing.rb
Instance Method Summary collapse
Instance Method Details
#transactional_tests_for_pool?(pool) ⇒ Boolean
73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 |
# File 'lib/active_record/tenanted/testing.rb', line 73 def transactional_tests_for_pool?(pool) config = pool.db_config # Prevent the tenanted BaseConfig from creating transactional fixtures on an unnecessary # database, which would result in sporadic locking errors. is_root_config = config.instance_of?(Tenanted::DatabaseConfigurations::BaseConfig) # Any tenanted database that isn't the default test fixture database should not be wrapped # in a transaction, for a couple of reasons: # # 1. we migrate the database using a temporary pool, which will wrap the schema load in a # transaction that will not be visible to any connection used by the code under test to # insert data. # 2. having an open transaction will prevent the test from being able to destroy the tenant. is_non_default_tenant = ( config.instance_of?(Tenanted::DatabaseConfigurations::TenantConfig) && config.tenant != Rails.application.config.active_record_tenanted.default_tenant.to_s ) return false if is_root_config || is_non_default_tenant super end |