Skip to content

Commit

Permalink
Merge pull request #294 from bdewater/remove-database-cleaner
Browse files Browse the repository at this point in the history
Replace DatabaseCleaner with Active Record to truncate tables
  • Loading branch information
Mangara authored Nov 2, 2022
2 parents 5e0147f + afc623b commit a32a143
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 12 deletions.
1 change: 0 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ gem "mysql2", github: "brianmario/mysql2"
gem "globalid"
gem "i18n"
gem "redis"
gem "database_cleaner"

gem "pry"
gem "mocha"
Expand Down
7 changes: 0 additions & 7 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,6 @@ GEM
coderay (1.1.3)
concurrent-ruby (1.1.10)
connection_pool (2.2.5)
database_cleaner (2.0.1)
database_cleaner-active_record (~> 2.0.0)
database_cleaner-active_record (2.0.1)
activerecord (>= 5.a)
database_cleaner-core (~> 2.0.0)
database_cleaner-core (2.0.1)
globalid (1.0.0)
activesupport (>= 5.0)
i18n (1.12.0)
Expand Down Expand Up @@ -108,7 +102,6 @@ PLATFORMS

DEPENDENCIES
activerecord
database_cleaner
globalid
i18n
job-iteration!
Expand Down
9 changes: 5 additions & 4 deletions test/test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
require "active_record"
require "pry"
require "mocha/minitest"
require "database_cleaner"

GlobalID.app = "iteration"
ActiveRecord::Base.include(GlobalID::Identification) # https://github.com/rails/globalid/blob/main/lib/global_id/railtie.rb
Expand Down Expand Up @@ -74,8 +73,6 @@ class Product < ActiveRecord::Base
t.timestamps
end

DatabaseCleaner.strategy = :truncation

module LoggingHelpers
def assert_logged(message)
old_logger = ActiveJob::Base.logger
Expand Down Expand Up @@ -117,12 +114,16 @@ class IterationUnitTest < ActiveSupport::TestCase

teardown do
ActiveJob::Base.queue_adapter.enqueued_jobs = []
DatabaseCleaner.clean
truncate_fixtures
end

def insert_fixtures
10.times do |n|
Product.create!(name: "lipstick #{n}")
end
end

def truncate_fixtures
ActiveRecord::Base.connection.truncate(Product.table_name)
end
end

0 comments on commit a32a143

Please sign in to comment.