Sha256: 4de624408ac6df00bab38fcbd7b1fa8af5824f85b48efecf03843b02ed633db7

Contents?: true

Size: 1.2 KB

Versions: 28

Compression:

Stored size: 1.2 KB

Contents

require 'test_helper'

module Workarea
  module Metrics
    class SearchByDayTest < TestCase
      def test_save_search
        travel_to Time.zone.local(2018, 11, 26)

        SearchByDay.save_search('', 3)
        assert_equal(0, SearchByDay.count)

        SearchByDay.save_search('a', 3)
        assert_equal(0, SearchByDay.count)

        SearchByDay.save_search('a', '')
        assert_equal(0, SearchByDay.count)

        2.times do
          SearchByDay.save_search('Foo  Bar', '3')
          assert_equal(1, SearchByDay.count)
        end

        search = SearchByDay.first
        assert_equal('20181126-foo_bar', search.id)
        assert_equal('foo_bar', search.query_id)
        assert_equal('foo bar', search.query_string)
        assert_equal(3, search.total_results)
        assert_equal(2, search.searches)
      end

      def test_save_search_typecasting
        SearchByDay.save_search(:foo, '0')
        assert_equal(1, SearchByDay.count)

        search = SearchByDay.first.as_document
        assert_equal('foo', search['query_id'])
        assert_equal('foo', search['query_string'])
        assert_equal(0, search['total_results'])
        assert_equal(1, search['searches'])
      end
    end
  end
end

Version data entries

28 entries across 28 versions & 1 rubygems

Version Path
workarea-core-3.5.27 test/models/workarea/metrics/search_by_day_test.rb
workarea-core-3.5.26 test/models/workarea/metrics/search_by_day_test.rb
workarea-core-3.5.25 test/models/workarea/metrics/search_by_day_test.rb
workarea-core-3.5.23 test/models/workarea/metrics/search_by_day_test.rb
workarea-core-3.5.22 test/models/workarea/metrics/search_by_day_test.rb
workarea-core-3.5.21 test/models/workarea/metrics/search_by_day_test.rb
workarea-core-3.5.20 test/models/workarea/metrics/search_by_day_test.rb
workarea-core-3.5.19 test/models/workarea/metrics/search_by_day_test.rb
workarea-core-3.5.18 test/models/workarea/metrics/search_by_day_test.rb
workarea-core-3.5.17 test/models/workarea/metrics/search_by_day_test.rb
workarea-core-3.5.16 test/models/workarea/metrics/search_by_day_test.rb
workarea-core-3.5.15 test/models/workarea/metrics/search_by_day_test.rb
workarea-core-3.5.14 test/models/workarea/metrics/search_by_day_test.rb
workarea-core-3.5.13 test/models/workarea/metrics/search_by_day_test.rb
workarea-core-3.5.12 test/models/workarea/metrics/search_by_day_test.rb
workarea-core-3.5.11 test/models/workarea/metrics/search_by_day_test.rb
workarea-core-3.5.10 test/models/workarea/metrics/search_by_day_test.rb
workarea-core-3.5.9 test/models/workarea/metrics/search_by_day_test.rb
workarea-core-3.5.8 test/models/workarea/metrics/search_by_day_test.rb
workarea-core-3.5.7 test/models/workarea/metrics/search_by_day_test.rb