Skip to content

Commit

Permalink
Fix NameError from nulldb (#34)
Browse files Browse the repository at this point in the history
nulldb is only loaded in the tests, so using its names in library code raised an exception:

```
NameError: uninitialized constant ActiveRecord::ConnectionAdapters::NullDBAdapter
```

We can instead key off the method that nulldb doesn't implement to fix the same issue as #32.
  • Loading branch information
adamstegman authored Dec 15, 2023
1 parent 465f700 commit abd18d0
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/acts_as_scrubbable/ar_class_processor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def process(num_of_batches)
end

ActsAsScrubbable.logger.info Term::ANSIColor.blue("#{scrubbed_count} #{ar_class} objects scrubbed")
ActiveRecord::Base.connection.verify! unless ActiveRecord::Base.connection.is_a?(ActiveRecord::ConnectionAdapters::NullDBAdapter)
ActiveRecord::Base.connection.verify! if ActiveRecord::Base.connection.respond_to?(:reconnect)

ActsAsScrubbable.logger.info Term::ANSIColor.white("Scrub Complete!")
end
Expand Down
2 changes: 1 addition & 1 deletion lib/acts_as_scrubbable/task_runner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def scrub(num_of_batches: nil, skip_before_hooks: false, skip_after_hooks: false
Parallel.each(ar_classes) do |ar_class|
ActsAsScrubbable::ArClassProcessor.new(ar_class).process(num_of_batches)
end
ActiveRecord::Base.connection.verify! unless ActiveRecord::Base.connection.is_a?(ActiveRecord::ConnectionAdapters::NullDBAdapter)
ActiveRecord::Base.connection.verify! if ActiveRecord::Base.connection.respond_to?(:reconnect)

after_hooks unless skip_after_hooks
end
Expand Down
2 changes: 1 addition & 1 deletion lib/acts_as_scrubbable/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module ActsAsScrubbable
VERSION = '2.1.2'
VERSION = '2.1.3'
end

0 comments on commit abd18d0

Please sign in to comment.