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.45 test/workers/workarea/process_search_recommendations_test.rb
workarea-core-3.4.44 test/workers/workarea/process_search_recommendations_test.rb
workarea-core-3.4.43 test/workers/workarea/process_search_recommendations_test.rb
workarea-core-3.4.42 test/workers/workarea/process_search_recommendations_test.rb
workarea-core-3.4.41 test/workers/workarea/process_search_recommendations_test.rb
workarea-core-3.4.40 test/workers/workarea/process_search_recommendations_test.rb
workarea-core-3.4.39 test/workers/workarea/process_search_recommendations_test.rb
workarea-core-3.4.38 test/workers/workarea/process_search_recommendations_test.rb
workarea-core-3.4.37 test/workers/workarea/process_search_recommendations_test.rb
workarea-core-3.4.36 test/workers/workarea/process_search_recommendations_test.rb
workarea-core-3.4.35 test/workers/workarea/process_search_recommendations_test.rb
workarea-core-3.4.34 test/workers/workarea/process_search_recommendations_test.rb
workarea-core-3.4.33 test/workers/workarea/process_search_recommendations_test.rb
workarea-core-3.4.32 test/workers/workarea/process_search_recommendations_test.rb
workarea-core-3.4.31 test/workers/workarea/process_search_recommendations_test.rb
workarea-core-3.4.30 test/workers/workarea/process_search_recommendations_test.rb
workarea-core-3.4.29 test/workers/workarea/process_search_recommendations_test.rb
workarea-core-3.4.28 test/workers/workarea/process_search_recommendations_test.rb
workarea-core-3.4.27 test/workers/workarea/process_search_recommendations_test.rb
workarea-core-3.4.26 test/workers/workarea/process_search_recommendations_test.rb