Commit 723e1b9de7e5a313f860bfeac1dc758d967ac32b

Authored by Andrew Kane
1 parent 1e9e0c96

Fixed tests

Showing 1 changed file with 9 additions and 1 deletions   Show diff stats
test/support/helpers.rb
@@ -33,7 +33,7 @@ class Minitest::Test @@ -33,7 +33,7 @@ class Minitest::Test
33 33
34 def store(documents, model = default_model, reindex: true) 34 def store(documents, model = default_model, reindex: true)
35 if reindex 35 if reindex
36 - Searchkick.callbacks(:bulk) do 36 + with_callbacks(:bulk) do
37 with_transaction(model) do 37 with_transaction(model) do
38 model.create!(documents.shuffle) 38 model.create!(documents.shuffle)
39 end 39 end
@@ -106,6 +106,14 @@ class Minitest::Test @@ -106,6 +106,14 @@ class Minitest::Test
106 end 106 end
107 end 107 end
108 108
  109 + def with_callbacks(value, &block)
  110 + if Searchkick.callbacks?(default: nil).nil?
  111 + Searchkick.callbacks(value, &block)
  112 + else
  113 + yield
  114 + end
  115 + end
  116 +
109 def with_transaction(model, &block) 117 def with_transaction(model, &block)
110 if model.respond_to?(:transaction) 118 if model.respond_to?(:transaction)
111 model.transaction(&block) 119 model.transaction(&block)