Commit 2aa586a227fcbb3d4545efd7e19b38eb0dd874a6
1 parent
8924adaf
Exists in
master
and in
2 other branches
Added log subscriber test for relation reindex [skip ci]
Showing
1 changed file
with
19 additions
and
2 deletions
Show diff stats
test/log_subscriber_test.rb
@@ -35,12 +35,29 @@ class LogSubscriberTest < Minitest::Test | @@ -35,12 +35,29 @@ class LogSubscriberTest < Minitest::Test | ||
35 | end | 35 | end |
36 | 36 | ||
37 | def test_reindex | 37 | def test_reindex |
38 | - Product.create!(name: "Product A") | 38 | + create_products |
39 | output = capture_logs do | 39 | output = capture_logs do |
40 | Product.reindex | 40 | Product.reindex |
41 | end | 41 | end |
42 | assert_match "Product Import", output | 42 | assert_match "Product Import", output |
43 | - assert_match '"count":1', output | 43 | + assert_match '"count":3', output |
44 | + end | ||
45 | + | ||
46 | + def test_reindex_relation | ||
47 | + products = create_products | ||
48 | + output = capture_logs do | ||
49 | + Product.where.not(id: products.last.id).reindex | ||
50 | + end | ||
51 | + assert_match "Product Import", output | ||
52 | + assert_match '"count":2', output | ||
53 | + end | ||
54 | + | ||
55 | + def create_products | ||
56 | + Searchkick.callbacks(false) do | ||
57 | + 3.times.map do | ||
58 | + Product.create!(name: "Product A") | ||
59 | + end | ||
60 | + end | ||
44 | end | 61 | end |
45 | 62 | ||
46 | def capture_logs | 63 | def capture_logs |