From 723e1b9de7e5a313f860bfeac1dc758d967ac32b Mon Sep 17 00:00:00 2001 From: Andrew Kane Date: Sun, 22 May 2022 23:31:34 -0700 Subject: [PATCH] Fixed tests --- test/support/helpers.rb | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) 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