diff --git a/test/support/helpers.rb b/test/support/helpers.rb index 11fa61e..67c7e57 100644 --- a/test/support/helpers.rb +++ b/test/support/helpers.rb @@ -33,7 +33,7 @@ class Minitest::Test def store(documents, model = default_model, reindex: true) if reindex - Searchkick.callbacks(:bulk) do + with_callbacks(:bulk) do with_transaction(model) do model.create!(documents.shuffle) end @@ -106,6 +106,14 @@ class Minitest::Test end end + def with_callbacks(value, &block) + if Searchkick.callbacks?(default: nil).nil? + Searchkick.callbacks(value, &block) + else + yield + end + end + def with_transaction(model, &block) if model.respond_to?(:transaction) model.transaction(&block) -- libgit2 0.21.0