Sha256: 1aec4925fc49cd883844e83d926071b4c4913af5f4f9a1fb800b2d78ad9dc15e

Contents?: true

Size: 875 Bytes

Versions: 2

Compression:

Stored size: 875 Bytes

Contents

require File.expand_path("../../test_helper", __FILE__)

class SearchFlip::ModelTest < SearchFlip::TestCase
  class TestProduct < Product
    include SearchFlip::Model

    notifies_index(ProductIndex)
  end

  def test_save
    assert_equal 0, ProductIndex.total_count

    TestProduct.create!

    assert_equal 1, ProductIndex.total_count
  end

  def test_destroy
    test_product = TestProduct.create!

    assert_equal 1, ProductIndex.total_count

    test_product.destroy

    assert_equal 0, ProductIndex.total_count
  end

  def test_touch
    test_product = Timecop.freeze(Time.parse("2016-01-01 12:00:00")) { TestProduct.create! }

    updated_at = ProductIndex.match_all.results.first.updated_at

    Timecop.freeze(Time.parse("2017-01-01 12:00:00")) { test_product.touch }

    refute_equal updated_at, ProductIndex.match_all.results.first.updated_at
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
search_flip-1.1.0 test/search_flip/model_test.rb
search_flip-1.0.0 test/search_flip/model_test.rb