Sha256: 86457ff246e52769698fc8a5941eeaa5da08e99dcfe2cad39ea3e0684bc314e9

Contents?: true

Size: 1.19 KB

Versions: 1

Compression:

Stored size: 1.19 KB

Contents

require 'test_helper'

module Workarea
  class BrowseOptionCategorizationTest < TestCase
    def test_manual
      product = create_product(
        browse_option: 'color',
        variants: [{ sku: 'SKU', details: { 'color' => 'red' } }]
      )

      category_one = create_category(product_ids: [product.id])
      category_two = create_category(
        product_ids: [BrowseOptionIds.build(product.id, 'red')]
      )
      category_three = create_category

      categorization = Categorization.new(product)
      assert(categorization.manual.include?(category_one.id))
      assert(categorization.manual.include?(category_two.id))
      refute(categorization.manual.include?(category_three.id))

      release = create_release(publish_at: 1.day.from_now)

      release.as_current do
        category_one.update!(product_ids: [])
        category_three.update!(
          product_ids: [BrowseOptionIds.build(product.id, 'red')]
        )

        categorization = Categorization.new(product)
        refute(categorization.manual.include?(category_one.id))
        assert(categorization.manual.include?(category_two.id))
        assert(categorization.manual.include?(category_three.id))
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
workarea-browse_option-2.2.0 test/queries/workarea/browse_option_categorization_test.rb