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.15 test/models/workarea/insights/popular_searches_without_results_test.rb
workarea-core-3.4.36 test/models/workarea/insights/popular_searches_without_results_test.rb
workarea-core-3.5.14 test/models/workarea/insights/popular_searches_without_results_test.rb
workarea-core-3.4.35 test/models/workarea/insights/popular_searches_without_results_test.rb
workarea-core-3.5.13 test/models/workarea/insights/popular_searches_without_results_test.rb
workarea-core-3.4.34 test/models/workarea/insights/popular_searches_without_results_test.rb
workarea-core-3.5.12 test/models/workarea/insights/popular_searches_without_results_test.rb
workarea-core-3.4.33 test/models/workarea/insights/popular_searches_without_results_test.rb
workarea-core-3.5.11 test/models/workarea/insights/popular_searches_without_results_test.rb
workarea-core-3.5.10 test/models/workarea/insights/popular_searches_without_results_test.rb
workarea-core-3.4.32 test/models/workarea/insights/popular_searches_without_results_test.rb
workarea-core-3.5.9 test/models/workarea/insights/popular_searches_without_results_test.rb
workarea-core-3.4.31 test/models/workarea/insights/popular_searches_without_results_test.rb
workarea-core-3.5.8 test/models/workarea/insights/popular_searches_without_results_test.rb
workarea-core-3.4.30 test/models/workarea/insights/popular_searches_without_results_test.rb
workarea-core-3.5.7 test/models/workarea/insights/popular_searches_without_results_test.rb
workarea-core-3.4.29 test/models/workarea/insights/popular_searches_without_results_test.rb
workarea-core-3.5.6 test/models/workarea/insights/popular_searches_without_results_test.rb
workarea-core-3.4.28 test/models/workarea/insights/popular_searches_without_results_test.rb
workarea-core-3.5.5 test/models/workarea/insights/popular_searches_without_results_test.rb