Sha256: 4176fac509dd5093e6084dc41636d725205a81f83b07ea9a2547b05065ec2d27
Contents?: true
Size: 1.73 KB
Versions: 1
Compression:
Stored size: 1.73 KB
Contents
require_relative "test_helper" class CallbacksTest < Minitest::Test def test_true_create Searchkick.callbacks(true) do store_names ["Product A", "Product B"] end Product.searchkick_index.refresh assert_search "product", ["Product A", "Product B"] end def test_false_create Searchkick.callbacks(false) do store_names ["Product A", "Product B"] end Product.searchkick_index.refresh assert_search "product", [] end def test_bulk_create Searchkick.callbacks(:bulk) do store_names ["Product A", "Product B"] end Product.searchkick_index.refresh assert_search "product", ["Product A", "Product B"] end def test_queue skip unless defined?(ActiveJob) && defined?(Redis) reindex_queue = Product.searchkick_index.reindex_queue reindex_queue.clear Searchkick.callbacks(:queue) do store_names ["Product A", "Product B"] end Product.searchkick_index.refresh assert_search "product", [], load: false assert_equal 2, reindex_queue.length Searchkick::ProcessQueueJob.perform_later(class_name: "Product") Product.searchkick_index.refresh assert_search "product", ["Product A", "Product B"], load: false assert_equal 0, reindex_queue.length Searchkick.callbacks(:queue) do Product.where(name: "Product B").destroy_all Product.create!(name: "Product C") end Product.searchkick_index.refresh assert_search "product", ["Product A", "Product B"], load: false assert_equal 2, reindex_queue.length Searchkick::ProcessQueueJob.perform_later(class_name: "Product") Product.searchkick_index.refresh assert_search "product", ["Product A", "Product C"], load: false assert_equal 0, reindex_queue.length end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
searchkick-2.0.4 | test/callbacks_test.rb |