Sha256: 20a2fcdf4243cb61ebc6124d3399a2d2c027562f4e2369b76f6ce1d4b0b7cffb

Contents?: true

Size: 980 Bytes

Versions: 5

Compression:

Stored size: 980 Bytes

Contents

require 'test_helper'

module Workarea
  class BrowseOptionIndexProductTest < TestCase
    include TestCase::SearchIndexing

    def test_perform
      product = create_product(id: '123||456+[789]  &&')

      IndexProduct.new.perform(product.id)
      assert(1, Search::Storefront::Product.count)

      product.update_attributes!(
        browse_option: 'color',
        variants: [
          { sku: 'SKU1', details: { color: ['Red'] } },
          { sku: 'SKU2', details: { color: ['Blue'] } }
        ]
      )

      IndexProduct.new.perform(product.id)
      assert(2, Search::Storefront::Product.count)
    end

    def test_clear
      Workarea::Search::Storefront.reset_indexes!

      foo_bar = create_product(id: 'FOO BAR')
      IndexProduct.perform(create_product(id: 'FOO'))
      IndexProduct.perform(create_product(id: 'BAR'))
      IndexProduct.perform(foo_bar)

      IndexProduct.clear(foo_bar)
      assert_equal(2, Search::Storefront.count)
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
workarea-browse_option-2.2.0 test/workers/workarea/browse_option_index_product_test.rb
workarea-browse_option-2.1.9 test/workers/workarea/browse_option_index_product_test.rb
workarea-browse_option-2.1.8 test/workers/workarea/browse_option_index_product_test.rb
workarea-browse_option-2.1.7 test/workers/workarea/browse_option_index_product_test.rb
workarea-browse_option-2.1.6 test/workers/workarea/browse_option_index_product_test.rb