diff --git a/lib/sphinx/integration/extensions/thinking_sphinx/last_indexing_time.rb b/lib/sphinx/integration/extensions/thinking_sphinx/last_indexing_time.rb index f4198c9..4ce0116 100644 --- a/lib/sphinx/integration/extensions/thinking_sphinx/last_indexing_time.rb +++ b/lib/sphinx/integration/extensions/thinking_sphinx/last_indexing_time.rb @@ -1,12 +1,24 @@ # coding: utf-8 -require 'redis-classy' +require 'redis' +require 'redis-namespace' module Sphinx::Integration::Extensions::ThinkingSphinx::LastIndexingTime extend ActiveSupport::Concern included do - class ThinkingSphinx::LastIndexing < ::Redis::Classy + class ThinkingSphinx::LastIndexing + def self.set(key, value) + redis.set(key, value) + end + + def self.get(key) + redis.get(key) + end + + def self.redis + @redis ||= Redis::Namespace.new(name, :redis => Redis.current) + end end # Public: Устанавливает время окончания последней успешной индексации. diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 5c26931..bea0e7d 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -7,21 +7,20 @@ require 'sphinx/integration/railtie' -require 'mock_redis' -require 'redis-classy' - -Redis::Classy.db = MockRedis.new - Combustion.initialize! :active_record require 'rspec/rails' +require 'mock_redis' +require 'redis-classy' + RSpec.configure do |config| config.backtrace_exclusion_patterns = [/lib\/rspec\/(core|expectations|matchers|mocks)/] config.color_enabled = true config.order = 'random' config.before(:each) do - Redis::Classy.db = MockRedis.new + Redis.current = MockRedis.new + Redis::Classy.db = Redis.current end end diff --git a/spec/sphinx/integration/extensions/thinking_sphinx/index/builder_spec.rb b/spec/sphinx/integration/extensions/thinking_sphinx/index/builder_spec.rb index 68f7c22..0c9b67d 100644 --- a/spec/sphinx/integration/extensions/thinking_sphinx/index/builder_spec.rb +++ b/spec/sphinx/integration/extensions/thinking_sphinx/index/builder_spec.rb @@ -60,7 +60,8 @@ end end - it { index.attributes.should have(4).item } # 3 internal + 1 user + # 4 internal (:sphinx_internal_id, :sphinx_deleted, :class_crc, :sphinx_internal_class) + 1 user + it { index.attributes.should have(5).item } it { index.attributes.select { |attr| attr.alias == :foo}.should be_present } end diff --git a/spec/sphinx/integration/extensions/thinking_sphinx/last_indexing_time_spec.rb b/spec/sphinx/integration/extensions/thinking_sphinx/last_indexing_time_spec.rb index e3cda9f..6535102 100644 --- a/spec/sphinx/integration/extensions/thinking_sphinx/last_indexing_time_spec.rb +++ b/spec/sphinx/integration/extensions/thinking_sphinx/last_indexing_time_spec.rb @@ -4,7 +4,7 @@ describe ThinkingSphinx do let(:time) { Time.now.utc } - before { ThinkingSphinx::LastIndexing.db.flushdb } + before { ThinkingSphinx::LastIndexing.redis.flushdb } before { ThinkingSphinx.stub(:db_current_time).and_return(time) } it do diff --git a/sphinx-integration.gemspec b/sphinx-integration.gemspec index f5560d2..f818aab 100644 --- a/sphinx-integration.gemspec +++ b/sphinx-integration.gemspec @@ -19,6 +19,8 @@ Gem::Specification.new do |gem| gem.add_runtime_dependency 'redis-classy', '~> 1.2.0' gem.add_runtime_dependency 'redis-mutex', '~> 2.1.0' + gem.add_runtime_dependency 'redis', '~> 3.0.7' + gem.add_runtime_dependency 'redis-namespace', '~> 1.3.0' gem.add_runtime_dependency 'mysql2', '>= 0.2.19b5' gem.add_runtime_dependency 'pg' gem.add_runtime_dependency 'innertube'