Commit e20575a4aabacf405e4dfa88fd914e5f81802476

Authored by Andrew
1 parent 734e0c1b

Added test for dangerous reindex with associations

Showing 2 changed files with 6 additions and 0 deletions   Show diff stats
test/index_test.rb
... ... @@ -107,6 +107,11 @@ class IndexTest < Minitest::Test
107 107 assert_raises(Searchkick::DangerousOperation) { Product.where(id: [1, 2, 3]).reindex }
108 108 end
109 109  
  110 + def test_dangerous_index_associations
  111 + Store.create!(name: "Test")
  112 + assert_raises(Searchkick::DangerousOperation) { Store.first.products.reindex }
  113 + end
  114 +
110 115 def test_dangerous_reindex_accepted
111 116 store_names ["Product A", "Product B"]
112 117 Product.where(name: "Product A").reindex(accept_danger: true)
... ...
test/test_helper.rb
... ... @@ -178,6 +178,7 @@ else
178 178 end
179 179  
180 180 class Store < ActiveRecord::Base
  181 + has_many :products
181 182 end
182 183  
183 184 class Animal < ActiveRecord::Base
... ...