Sha256: 738d2b6d6881e8880b007dcfd2886882c68c350dadf4c599c431c180c166bddb

Contents?: true

Size: 1 KB

Versions: 14

Compression:

Stored size: 1 KB

Contents

require_relative "test_helper"

class ModelTest < Minitest::Test
  def test_disable_callbacks_model
    store_names ["product a"]

    Product.disable_search_callbacks
    assert !Product.search_callbacks?

    store_names ["product b"]
    assert_search "product", ["product a"]

    Product.enable_search_callbacks
    Product.reindex

    assert_search "product", ["product a", "product b"]
  end

  def test_disable_callbacks_global
    # make sure callbacks default to on
    assert Searchkick.callbacks?

    store_names ["product a"]

    Searchkick.disable_callbacks
    assert !Searchkick.callbacks?

    store_names ["product b"]
    assert_search "product", ["product a"]

    Searchkick.enable_callbacks
    Product.reindex

    assert_search "product", ["product a", "product b"]
  end

  def test_multiple_models
    store_names ["Product A"]
    store_names ["Product B"], Store
    assert_equal Product.all + Store.all, Searchkick.search("product", index_name: [Product, Store], order: "name").to_a
  end
end

Version data entries

14 entries across 14 versions & 2 rubygems

Version Path
searchkick-1.4.2 test/model_test.rb
searchkick-1.4.1 test/model_test.rb
searchkick-1.4.0 test/model_test.rb
searchkick-1.3.6 test/model_test.rb
searchkick-1.3.5 test/model_test.rb
searchkick-1.3.4 test/model_test.rb
searchkick-1.3.3 test/model_test.rb
searchkick-1.3.2 test/model_test.rb
searchkick_bharthur-0.0.2 test/model_test.rb
searchkick_bharthur-0.0.1 test/model_test.rb
searchkick-1.3.1 test/model_test.rb
searchkick-1.3.0 test/model_test.rb
searchkick-1.2.1 test/model_test.rb
searchkick-1.2.0 test/model_test.rb