Sha256: eeea01c3fe4b7460ae4ddaa94a0b42b876e6f5ffd33b77caa2fd782c088f2080

Contents?: true

Size: 1.51 KB

Versions: 28

Compression:

Stored size: 1.51 KB

Contents

require 'test_helper'

module Workarea
  class QueryCacheMiddlewareTest < TestCase
    class FooWorker
      class << self
        def sidekiq_options=(value)
          @sidekiq_options = value
        end

        def sidekiq_options
          @sidekiq_options || {}
        end
      end
    end

    def test_call
      QueryCacheMiddleware.new({}).call(FooWorker.new, {}, :foo) do
        refute(Mongoid::QueryCache.enabled?)
        refute(Elasticsearch::QueryCache.enabled?)
      end

      FooWorker.sidekiq_options = { 'query_cache' => true }

      QueryCacheMiddleware.new({}).call(FooWorker.new, {}, :foo) do
        assert(Mongoid::QueryCache.enabled?)
        assert(Elasticsearch::QueryCache.enabled?)
      end

      FooWorker.sidekiq_options = { 'mongoid_query_cache' => true }

      QueryCacheMiddleware.new({}).call(FooWorker.new, {}, :foo) do
        assert(Mongoid::QueryCache.enabled?)
        refute(Elasticsearch::QueryCache.enabled?)
      end

      FooWorker.sidekiq_options = { 'elasticsearch_query_cache' => true }

      QueryCacheMiddleware.new({}).call(FooWorker.new, {}, :foo) do
        refute(Mongoid::QueryCache.enabled?)
        assert(Elasticsearch::QueryCache.enabled?)
      end

      FooWorker.sidekiq_options = {
        'elasticsearch_query_cache' => true,
        'mongoid_query_cache' => true
      }

      QueryCacheMiddleware.new({}).call(FooWorker.new, {}, :foo) do
        assert(Mongoid::QueryCache.enabled?)
        assert(Elasticsearch::QueryCache.enabled?)
      end
    end
  end
end

Version data entries

28 entries across 28 versions & 1 rubygems

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