Sha256: 076b90746a454e1a289faf68fb9b96cd74d1975ddc0ca9c87a088fb867bbb321

Contents?: true

Size: 1.21 KB

Versions: 62

Compression:

Stored size: 1.21 KB

Contents

require 'test_helper'

module Workarea
  class BulkIndexSearchesTest < TestCase
    include TestCase::SearchIndexing

    setup :set_config
    teardown :unset_config

    def set_config
      @current_max = Workarea.config.max_searches_to_index
      Workarea.config.max_searches_to_index = 3
    end

    def unset_config
      Workarea.config.max_searches_to_index = @current_max
    end

    def test_perform
      Search::Storefront.reset_indexes!

      2.times do
        Metrics::SearchByDay.save_search('foo', 1)
        2.times { Metrics::SearchByDay.save_search('bar', 2) }
        3.times { Metrics::SearchByDay.save_search('baz', 3) }
        4.times { Metrics::SearchByDay.save_search('qux', 4) }
        5.times { Metrics::SearchByDay.save_search('qoo', 0) }

        travel_to 1.week.from_now
        GenerateInsights.generate_all!
        BulkIndexSearches.perform
      end

      assert_equal(3, Search::Storefront.count)

      results = Search::Storefront.search('*')['hits']['hits']
      names = results.map { |r| r['_source']['content']['name'] }

      assert_includes(names, 'qux')
      assert_includes(names, 'baz')
      assert_includes(names, 'bar')
      refute_includes(names, 'qoo')
    end
  end
end

Version data entries

62 entries across 62 versions & 1 rubygems

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