Sha256: 314ebb0ee76b387cc60e8a510be25c1a53008668f76ecfe18310f5d3591dbbae

Contents?: true

Size: 1.36 KB

Versions: 5

Compression:

Stored size: 1.36 KB

Contents

require 'test_helper'

module Workarea
  decorate Search::RelatedProductsTest, with: :browse_option do
    def test_browse_option_search_product_ids
      products = Array.new(2) { create_product }
      browse_option_product = products.first
      browse_option_product.update_attributes!(
        browse_option: 'color',
        variants: [
          { sku: 'SKU1', details: { color: ['Red'] } },
          { sku: 'SKU2', details: { color: ['Blue'] } }
        ]
      )
      query = Search::RelatedProducts.new(product_ids: products.map(&:id))

      assert_includes(query.search_product_ids, "product-#{products.second.id}")
      assert_includes(query.search_product_ids, "product-#{browse_option_product.id}-red")
      assert_includes(query.search_product_ids, "product-#{browse_option_product.id}-blue")
    end

    def test_browse_option_exclude_search_product_ids
      products = Array.new(2) { create_product }
      products.first.update_attributes!(
        browse_option: 'color',
        variants: [
          { sku: 'SKU1', details: { color: ['Red'] } },
          { sku: 'SKU2', details: { color: ['Blue'] } }
        ]
      )
      query = Search::RelatedProducts.new(
        product_ids: products.map(&:id),
        exclude_product_ids: products.last.id
      )

      assert_includes(query.exclude_search_product_ids, "product-#{products.last.id}")
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
workarea-browse_option-2.2.0 test/queries/workarea/search/related_products_test.decorator
workarea-browse_option-2.1.9 test/queries/workarea/search/related_products_test.decorator
workarea-browse_option-2.1.8 test/queries/workarea/search/related_products_test.decorator
workarea-browse_option-2.1.7 test/queries/workarea/search/related_products_test.decorator
workarea-browse_option-2.1.6 test/queries/workarea/search/related_products_test.decorator