Sha256: d15845864c52651746c58ec8368e0893047d3c0dc9459d7a131db57be5c80c41

Contents?: true

Size: 956 Bytes

Versions: 34

Compression:

Stored size: 956 Bytes

Contents

require 'test_helper'

module Workarea
  class ProcessSearchRecommendationsTest < Workarea::TestCase
    def test_processing_user_activity
      Recommendation::UserActivity.create!(searches: %w(foo bars))
      Recommendation::UserActivity.create!(searches: %w(foo @#$%))
      2.times { Recommendation::UserActivity.create!(searches: %w(foos baz)) }

      ProcessSearchRecommendations.new.perform

      predictor = Recommendation::SearchPredictor.new
      assert_equal(%w(baz bar), predictor.similarities_for('foo'))
    end

    def test_within_expiration
      Recommendation::UserActivity.create!(searches: %w(1 2))
      travel_to((Workarea.config.recommendation_expiration + 1.day).from_now)
      2.times { Recommendation::UserActivity.create!(searches: %w(1 3)) }

      ProcessSearchRecommendations.new.perform

      predictor = Recommendation::SearchPredictor.new
      assert_equal(%w(3), predictor.similarities_for('1'))
    end
  end
end

Version data entries

34 entries across 34 versions & 1 rubygems

Version Path
workarea-core-3.4.25 test/workers/workarea/process_search_recommendations_test.rb
workarea-core-3.4.24 test/workers/workarea/process_search_recommendations_test.rb
workarea-core-3.4.23 test/workers/workarea/process_search_recommendations_test.rb
workarea-core-3.4.22 test/workers/workarea/process_search_recommendations_test.rb
workarea-core-3.4.21 test/workers/workarea/process_search_recommendations_test.rb
workarea-core-3.4.20 test/workers/workarea/process_search_recommendations_test.rb
workarea-core-3.4.19 test/workers/workarea/process_search_recommendations_test.rb
workarea-core-3.4.18 test/workers/workarea/process_search_recommendations_test.rb
workarea-core-3.4.17 test/workers/workarea/process_search_recommendations_test.rb
workarea-core-3.4.16 test/workers/workarea/process_search_recommendations_test.rb
workarea-core-3.4.15 test/workers/workarea/process_search_recommendations_test.rb
workarea-core-3.4.14 test/workers/workarea/process_search_recommendations_test.rb
workarea-core-3.4.13 test/workers/workarea/process_search_recommendations_test.rb
workarea-core-3.4.12 test/workers/workarea/process_search_recommendations_test.rb