From 2aa586a227fcbb3d4545efd7e19b38eb0dd874a6 Mon Sep 17 00:00:00 2001 From: Andrew Kane Date: Fri, 18 Feb 2022 18:14:40 -0800 Subject: [PATCH] Added log subscriber test for relation reindex [skip ci] --- test/log_subscriber_test.rb | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/test/log_subscriber_test.rb b/test/log_subscriber_test.rb index d273e16..6755d8f 100644 --- a/test/log_subscriber_test.rb +++ b/test/log_subscriber_test.rb @@ -35,12 +35,29 @@ class LogSubscriberTest < Minitest::Test end def test_reindex - Product.create!(name: "Product A") + create_products output = capture_logs do Product.reindex end assert_match "Product Import", output - assert_match '"count":1', output + assert_match '"count":3', output + end + + def test_reindex_relation + products = create_products + output = capture_logs do + Product.where.not(id: products.last.id).reindex + end + assert_match "Product Import", output + assert_match '"count":2', output + end + + def create_products + Searchkick.callbacks(false) do + 3.times.map do + Product.create!(name: "Product A") + end + end end def capture_logs -- libgit2 0.21.0