Skip to content

Commit

Permalink
feature(indexing): отказался от наследования от classy
Browse files Browse the repository at this point in the history
  • Loading branch information
Napolskih committed Sep 22, 2014
1 parent 3b55a00 commit 60db7c9
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 10 deletions.
Original file line number Diff line number Diff line change
@@ -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: Устанавливает время окончания последней успешной индексации.
Expand Down
11 changes: 5 additions & 6 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions sphinx-integration.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down

0 comments on commit 60db7c9

Please sign in to comment.