Sha256: 3041e5f72cdd4294b5af7c253598a06312ff9bf3f13d3c34346f03fe9e653c34

Contents?: true

Size: 1.44 KB

Versions: 5

Compression:

Stored size: 1.44 KB

Contents

require 'test_helper'

module Workarea
  decorate BulkIndexProductsTest, with: :browse_option do
    def test_peform
      Workarea::Search::Storefront.reset_indexes!

      Sidekiq::Callbacks.disable(IndexProduct) do
        products = 2.times.map { |n| create_product(id: "PRODUCT     #{n}") }

        assert_equal(0, Search::Storefront.count)
        BulkIndexProducts.new.perform(products.map(&:id))
        assert_equal(2, Search::Storefront.count)

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

        assert_equal(2, Search::Storefront.count)
        BulkIndexProducts.new.perform(products.map(&:id))
        assert_equal(3, Search::Storefront.count)
      end
    end

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

      Sidekiq::Callbacks.disable(IndexProduct) do
        product_one = create_product
        product_two = create_product(
          browse_option: 'color',
          variants: [
            { sku: 'SKU1', details: { color: ['Red'] } },
            { sku: 'SKU2', details: { color: ['Blue'] } }
          ]
        )

        BulkIndexProducts.new.perform(
          [product_one.id, *BrowseOptionIds.all_for(product_two)]
        )
        assert_equal(3, Search::Storefront.count)
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
workarea-browse_option-2.2.0 test/workers/workarea/bulk_index_products_test.decorator
workarea-browse_option-2.1.9 test/workers/workarea/bulk_index_products_test.decorator
workarea-browse_option-2.1.8 test/workers/workarea/bulk_index_products_test.decorator
workarea-browse_option-2.1.7 test/workers/workarea/bulk_index_products_test.decorator
workarea-browse_option-2.1.6 test/workers/workarea/bulk_index_products_test.decorator