Commit 723e1b9de7e5a313f860bfeac1dc758d967ac32b
1 parent
1e9e0c96
Exists in
master
and in
1 other branch
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 | 33 | |
34 | 34 | def store(documents, model = default_model, reindex: true) |
35 | 35 | if reindex |
36 | - Searchkick.callbacks(:bulk) do | |
36 | + with_callbacks(:bulk) do | |
37 | 37 | with_transaction(model) do |
38 | 38 | model.create!(documents.shuffle) |
39 | 39 | end |
... | ... | @@ -106,6 +106,14 @@ class Minitest::Test |
106 | 106 | end |
107 | 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 | 117 | def with_transaction(model, &block) |
110 | 118 | if model.respond_to?(:transaction) |
111 | 119 | model.transaction(&block) | ... | ... |