Sha256: 2ed33511dc8c2101efacc774740c7dae69860fa9dd4b35cb73e01455e02422d8

Contents?: true

Size: 1.22 KB

Versions: 62

Compression:

Stored size: 1.22 KB

Contents

require 'test_helper'

module Workarea
  module Insights
    class PopularSearchesWithoutResultsTest < TestCase
      def test_results
        Metrics::SearchByDay.save_search('foo', 0, at: Time.zone.local(2018, 10, 27))
        Metrics::SearchByDay.save_search('foo', 0, at: Time.zone.local(2018, 10, 27))
        Metrics::SearchByDay.save_search('foo', 0, at: Time.zone.local(2018, 10, 27))
        Metrics::SearchByDay.save_search('bar', 0, at: Time.zone.local(2018, 10, 27))
        Metrics::SearchByDay.save_search('bar', 0, at: Time.zone.local(2018, 10, 27))
        Metrics::SearchByDay.save_search('baz', 1, at: Time.zone.local(2018, 10, 27))

        travel_to Time.zone.local(2018, 11, 1)

        PopularSearchesWithoutResults.generate_monthly!
        assert_equal(1, PopularSearchesWithoutResults.count)

        popular_searches = PopularSearchesWithoutResults.first
        assert_equal(2, popular_searches.results.size)
        assert_equal('foo', popular_searches.results.first['query_string'])
        assert_equal(3, popular_searches.results.first['searches'])
        assert_equal('bar', popular_searches.results.second['query_string'])
        assert_equal(2, popular_searches.results.second['searches'])
      end
    end
  end
end

Version data entries

62 entries across 62 versions & 1 rubygems

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