Sha256: 8fa15f854ffdf2770993c1a82254f0d1055f447724a03521903f836212c4355b

Contents?: true

Size: 983 Bytes

Versions: 28

Compression:

Stored size: 983 Bytes

Contents

require 'test_helper'

module Workarea
  module Recommendation
    class UserActivityBasedTest < IntegrationTest
      setup :create_products

      def create_products
        @one = create_product(id: '1')
        @two = create_product(id: '2')
        @three = create_product(id: '3')

        create_top_products(
          results: [
            { 'product_id' => '1' },
            { 'product_id' => '2' },
            { 'product_id' => '3' }
          ]
        )
      end

      def test_using_popular_products_if_blank
        metrics = Metrics::User.new
        query = UserActivityBased.new(metrics)
        assert_equal(%w(1 2 3), query.results)
      end

      def test_using_related_products
        metrics = Metrics::User.new(viewed: { product_ids: %w(1) })
        query = UserActivityBased.new(metrics)
        assert_equal(2, query.results.size)
        assert_includes(query.results, '2')
        assert_includes(query.results, '3')
      end
    end
  end
end

Version data entries

28 entries across 28 versions & 1 rubygems

Version Path
workarea-core-3.5.6 test/queries/workarea/recommendation/user_activity_based_test.rb
workarea-core-3.5.5 test/queries/workarea/recommendation/user_activity_based_test.rb
workarea-core-3.5.4 test/queries/workarea/recommendation/user_activity_based_test.rb
workarea-core-3.5.3 test/queries/workarea/recommendation/user_activity_based_test.rb
workarea-core-3.5.2 test/queries/workarea/recommendation/user_activity_based_test.rb
workarea-core-3.5.1 test/queries/workarea/recommendation/user_activity_based_test.rb
workarea-core-3.5.0 test/queries/workarea/recommendation/user_activity_based_test.rb
workarea-core-3.5.0.beta.1 test/queries/workarea/recommendation/user_activity_based_test.rb