Sha256: df300b9b43b4466915fe3005a47aab11e0f36ff2bf5c1ccb34788253b5ad1fd7

Contents?: true

Size: 1.19 KB

Versions: 1

Compression:

Stored size: 1.19 KB

Contents

# frozen_string_literal: true

require 'spec_helper'

describe 'products', type: :system, caching: true do
  let!(:product) { create(:product) }
  let!(:product2) { create(:product) }
  let!(:taxonomy) { create(:taxonomy) }
  let!(:taxon) { create(:taxon, taxonomy: taxonomy) }

  before do
    product2.update_column(:updated_at, 1.day.ago)
    # warm up the cache
    visit spree.root_path

    clear_cache_events
  end

  it "reads from cache upon a second viewing" do
    visit spree.root_path
    expect(cache_writes.count).to eq(0)
  end

  it "busts the cache when a product is updated" do
    product.update_column(:updated_at, 1.day.from_now)
    visit spree.root_path
    expect(cache_writes.count).to eq(2)
  end

  it "busts the cache when all products are soft-deleted" do
    product.discard
    product2.discard
    visit spree.root_path
    expect(cache_writes.count).to eq(1)
  end

  it "busts the cache when the newest product is soft-deleted" do
    product.discard
    visit spree.root_path
    expect(cache_writes.count).to eq(1)
  end

  it "busts the cache when an older product is soft-deleted" do
    product2.discard
    visit spree.root_path
    expect(cache_writes.count).to eq(1)
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
solidus_starter_frontend-0.1.0 spec/system/caching/products_spec.rb