Skip to content

v2.2.1 can overwrite DatabaseCleaner.strategy #126

@aalong-tr

Description

@aalong-tr

On v2.2.0 of this gem, this config worked fine in my app:

RSpec.configure do |config|
  # ...
  DatabaseCleaner.strategy = :truncation
end

After upgrading to v2.2.1, my strategy was getting overwritten and set to transaction. I only noticed this because that strategy has never worked properly with the Sqlite3 memory database I use for this library, which meant that the overwrite was causing some errors. I was able to restore the original behavior with:

RSpec.configure do |config|
  # ...

  config.before(:suite) do
    DatabaseCleaner.strategy = :truncation
  end
end

My best guess is that https://github.com/fatkodima/database_cleaner-active_record/blob/63aec2d25d6cac1322df926689ec33daf491de0e/lib/database_cleaner/active_record.rb#L10 needs to be ||= instead of =, but I defer to the subject matter experts.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions