Sha256: dc6f4ed9507d7bb4d2b2ef53e8ea22a329cfcc6ee95c7afd168e64d0247c7445

Contents?: true

Size: 1.03 KB

Versions: 39

Compression:

Stored size: 1.03 KB

Contents

require File.expand_path("../spec_helper", __dir__)

class TestProduct < Product
  include SearchFlip::Model

  notifies_index(ProductIndex)
end

RSpec.describe SearchFlip::Model do
  describe "#save" do
    it "imports the record to the index" do
      expect(ProductIndex.total_count).to eq(0)

      TestProduct.create!

      expect(ProductIndex.total_count).to eq(1)
    end
  end

  describe "#destroy" do
    it "delete the record from the index" do
      test_product = TestProduct.create!

      expect(ProductIndex.total_count).to eq(1)

      test_product.destroy

      expect(ProductIndex.total_count).to eq(0)
    end
  end

  describe "#touch" do
    it "imports the record to the index" do
      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 }

      expect(ProductIndex.match_all.results.first.updated_at).not_to eq(updated_at)
    end
  end
end

Version data entries

39 entries across 39 versions & 1 rubygems

Version Path
search_flip-3.9.0 spec/search_flip/model_spec.rb
search_flip-4.0.0.beta16 spec/search_flip/model_spec.rb
search_flip-4.0.0.beta15 spec/search_flip/model_spec.rb
search_flip-4.0.0.beta14 spec/search_flip/model_spec.rb
search_flip-3.8.0 spec/search_flip/model_spec.rb
search_flip-4.0.0.beta13 spec/search_flip/model_spec.rb
search_flip-3.7.2 spec/search_flip/model_spec.rb
search_flip-4.0.0.beta12 spec/search_flip/model_spec.rb
search_flip-3.7.1 spec/search_flip/model_spec.rb
search_flip-4.0.0.beta11 spec/search_flip/model_spec.rb
search_flip-3.7.0 spec/search_flip/model_spec.rb
search_flip-4.0.0.beta10 spec/search_flip/model_spec.rb
search_flip-3.6.0 spec/search_flip/model_spec.rb
search_flip-3.5.0 spec/search_flip/model_spec.rb
search_flip-4.0.0.beta9 spec/search_flip/model_spec.rb
search_flip-4.0.0.beta8 spec/search_flip/model_spec.rb
search_flip-3.4.0 spec/search_flip/model_spec.rb
search_flip-3.3.0 spec/search_flip/model_spec.rb
search_flip-4.0.0.beta7 spec/search_flip/model_spec.rb
search_flip-4.0.0.beta6 spec/search_flip/model_spec.rb