Sha256: 9725be2122a0a759dfef4b2b440ef3e4c35072e9f2fbb960a6243261cc1f07bc

Contents?: true

Size: 1.2 KB

Versions: 62

Compression:

Stored size: 1.2 KB

Contents

require 'test_helper'

module Workarea
  module Recommendation
    class OrderBasedTest < IntegrationTest
      setup :create_products

      def create_products
        create_product(id: '1')
        create_product(id: '2')
        create_product(id: '3')
      end

      def test_results
        create_product(id: '4')

        Order.create!(
          placed_at: Time.current,
          items: [
            { product_id: '1', sku: 'SKU' },
            { product_id: '2', sku: 'SKU' }
          ]
        )

        2.times do
          Order.create!(
            placed_at: Time.current,
            items: [
              { product_id: '1', sku: 'SKU' },
              { product_id: '3', sku: 'SKU' }
            ]
          )
        end

        ProcessProductRecommendations.new.perform

        order = Order.new(items: [{ product_id: '1' }])
        assert_equal(%w(3 2 4), OrderBased.new(order).results)
      end

      def test_falling_back_to_related_products
        order = Order.new(items: [{ product_id: '1' }])
        query = OrderBased.new(order)

        assert_equal(2, query.results.size)
        assert_includes(query.results, '2')
        assert_includes(query.results, '3')
      end
    end
  end
end

Version data entries

62 entries across 62 versions & 1 rubygems

Version Path
workarea-core-3.5.27 test/queries/workarea/recommendation/order_based_test.rb
workarea-core-3.5.26 test/queries/workarea/recommendation/order_based_test.rb
workarea-core-3.4.45 test/queries/workarea/recommendation/order_based_test.rb
workarea-core-3.5.25 test/queries/workarea/recommendation/order_based_test.rb
workarea-core-3.5.23 test/queries/workarea/recommendation/order_based_test.rb
workarea-core-3.4.44 test/queries/workarea/recommendation/order_based_test.rb
workarea-core-3.5.22 test/queries/workarea/recommendation/order_based_test.rb
workarea-core-3.4.43 test/queries/workarea/recommendation/order_based_test.rb
workarea-core-3.5.21 test/queries/workarea/recommendation/order_based_test.rb
workarea-core-3.4.42 test/queries/workarea/recommendation/order_based_test.rb
workarea-core-3.5.20 test/queries/workarea/recommendation/order_based_test.rb
workarea-core-3.4.41 test/queries/workarea/recommendation/order_based_test.rb
workarea-core-3.5.19 test/queries/workarea/recommendation/order_based_test.rb
workarea-core-3.4.40 test/queries/workarea/recommendation/order_based_test.rb
workarea-core-3.5.18 test/queries/workarea/recommendation/order_based_test.rb
workarea-core-3.4.39 test/queries/workarea/recommendation/order_based_test.rb
workarea-core-3.5.17 test/queries/workarea/recommendation/order_based_test.rb
workarea-core-3.4.38 test/queries/workarea/recommendation/order_based_test.rb
workarea-core-3.5.16 test/queries/workarea/recommendation/order_based_test.rb
workarea-core-3.4.37 test/queries/workarea/recommendation/order_based_test.rb