Sha256: 791a9e6d3cb22a1bf4402366a57ae04e0a379fdc6df7114f912869474d9722b9

Contents?: true

Size: 1.19 KB

Versions: 9

Compression:

Stored size: 1.19 KB

Contents

require_relative "test_helper"

class TestIndex < Minitest::Unit::TestCase

  def test_clean_indices
    old_index = Searchkick::Index.new("products_test_20130801000000000")
    different_index = Searchkick::Index.new("items_test_20130801000000000")

    old_index.delete if old_index.exists?
    different_index.delete if different_index.exists?

    # create indexes
    old_index.create
    different_index.create

    Product.clean_indices

    assert Product.searchkick_index.exists?
    assert different_index.exists?
    assert !old_index.exists?
  end

  def test_clean_indices_old_format
    old_index = Searchkick::Index.new("products_test_20130801000000")
    old_index.create

    Product.clean_indices

    assert !old_index.exists?
  end

  def test_mapping
    store_names ["Dollar Tree"], Store
    assert_equal [], Store.search(query: {match: {name: "dollar"}}).map(&:name)
    assert_equal ["Dollar Tree"], Store.search(query: {match: {name: "Dollar Tree"}}).map(&:name)
  end

  if defined?(ActiveRecord)

    def test_transaction
      Product.transaction do
        store_names ["Product A"]
        raise ActiveRecord::Rollback
      end

      assert_search "product", []
    end

  end

end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
searchkick-0.7.4 test/index_test.rb
searchkick-0.7.3 test/index_test.rb
searchkick-0.7.2 test/index_test.rb
searchkick-0.7.1 test/index_test.rb
searchkick-0.7.0 test/index_test.rb
searchkick-0.6.3 test/index_test.rb
searchkick-0.6.2 test/index_test.rb
searchkick-0.6.1 test/index_test.rb
searchkick-0.6.0 test/index_test.rb