Sha256: 24dc47381c0b47ffdae9c359a4a3dbc2a7710dcf2dfbe0a1338e7ecdeccaa293

Contents?: true

Size: 969 Bytes

Versions: 62

Compression:

Stored size: 969 Bytes

Contents

require 'test_helper'

module Workarea
  module Search
    class CategorizationTest < TestCase
      include TestCase::SearchIndexing

      def test_categorization_filtering
        create_product
        product_one = create_product
        product_two = create_product
        category_one = create_category(product_ids: [product_one.id])
        category_two = create_category(product_ids: [product_two.id])
        BulkIndexProducts.perform

        search = Categorization.new(category_ids: [category_one.id])
        assert_equal([product_one], search.results)

        search = Categorization.new(category_ids: [category_two.id])
        assert_equal([product_two], search.results)

        search = Categorization.new(
          category_ids: [category_one.id, category_two.id]
        )
        assert_equal(2, search.total)
        assert_includes(search.results, product_one)
        assert_includes(search.results, product_two)
      end
    end
  end
end

Version data entries

62 entries across 62 versions & 1 rubygems

Version Path
workarea-core-3.4.13 test/queries/workarea/search/categorization_test.rb
workarea-core-3.4.12 test/queries/workarea/search/categorization_test.rb