Skip to content

Commit

Permalink
Do not load ActiveRecord too early (#104)
Browse files Browse the repository at this point in the history
  • Loading branch information
fatkodima authored Jul 17, 2024
1 parent af3b015 commit d34716a
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 12 deletions.
14 changes: 9 additions & 5 deletions lib/database_cleaner/active_record.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
require 'database_cleaner/active_record/version'
require 'active_record'
require 'database_cleaner/core'
require 'database_cleaner/active_record/transaction'
require 'database_cleaner/active_record/truncation'
require 'database_cleaner/active_record/deletion'

DatabaseCleaner[:active_record].strategy = :transaction
ActiveSupport.on_load(:active_record) do
require 'database_cleaner/active_record/base'
require 'database_cleaner/active_record/transaction'
require 'database_cleaner/active_record/truncation'
require 'database_cleaner/active_record/deletion'

DatabaseCleaner[:active_record].strategy = :transaction
end
1 change: 0 additions & 1 deletion lib/database_cleaner/active_record/base.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
require 'active_record'
require 'database_cleaner/strategy'
require 'erb'
require 'yaml'
Expand Down
3 changes: 0 additions & 3 deletions lib/database_cleaner/active_record/deletion.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
require 'active_record'
require 'database_cleaner/active_record/truncation'

module DatabaseCleaner
module ActiveRecord
class Deletion < Truncation
Expand Down
2 changes: 0 additions & 2 deletions lib/database_cleaner/active_record/transaction.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
require 'database_cleaner/active_record/base'

module DatabaseCleaner
module ActiveRecord
class Transaction < Base
Expand Down
1 change: 0 additions & 1 deletion lib/database_cleaner/active_record/truncation.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
require "delegate"
require 'database_cleaner/active_record/base'

module DatabaseCleaner
module ActiveRecord
Expand Down
2 changes: 2 additions & 0 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@

require 'database_cleaner-active_record'

ActiveRecord::Base # load active record

RSpec.configure do |config|
# These two settings work together to allow you to limit a spec run
# to individual examples or groups you care about by tagging them with
Expand Down

0 comments on commit d34716a

Please sign in to comment.