ts-delayed-delta 1.1.3 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +1 -0
- data/.travis.yml +14 -12
- data/Appraisals +11 -0
- data/Gemfile +1 -3
- data/LICENSE +1 -1
- data/README.textile +29 -26
- data/Rakefile +3 -16
- data/gemfiles/binary.gemfile +7 -0
- data/gemfiles/sphinxql.gemfile +7 -0
- data/lib/thinking_sphinx/deltas/delayed_delta.rb +117 -47
- data/lib/thinking_sphinx/deltas/delayed_delta/delta_job.rb +7 -16
- data/lib/thinking_sphinx/deltas/delayed_delta/flag_as_deleted_job.rb +8 -19
- data/lib/ts-delayed-delta.rb +0 -3
- data/spec/acceptance/delayed_job_deltas_spec.rb +46 -0
- data/spec/acceptance/spec_helper.rb +4 -0
- data/spec/acceptance/support/database_cleaner.rb +11 -0
- data/spec/acceptance/support/sphinx_controller.rb +61 -0
- data/spec/acceptance/support/sphinx_helpers.rb +31 -0
- data/spec/internal/.gitignore +2 -0
- data/spec/internal/app/indices/book_index.rb +3 -0
- data/spec/internal/app/models/book.rb +7 -0
- data/spec/internal/config/database.yml +5 -0
- data/spec/internal/db/schema.rb +24 -0
- data/spec/internal/log/.gitignore +1 -0
- data/spec/spec_helper.rb +9 -7
- data/ts-delayed-delta.gemspec +15 -11
- metadata +129 -86
- data/VERSION +0 -1
- data/features/delayed_deltas.feature +0 -37
- data/features/step_definitions/common_steps.rb +0 -48
- data/features/step_definitions/delayed_delta_steps.rb +0 -11
- data/features/support/env.rb +0 -33
- data/features/thinking_sphinx/database.example.yml +0 -3
- data/features/thinking_sphinx/db/fixtures/delayed_betas.rb +0 -10
- data/features/thinking_sphinx/db/migrations/create_delayed_betas.rb +0 -17
- data/features/thinking_sphinx/models/delayed_beta.rb +0 -7
- data/lib/thinking_sphinx/deltas/delayed_delta/job.rb +0 -65
- data/lib/thinking_sphinx/deltas/delayed_delta/railtie.rb +0 -5
- data/lib/thinking_sphinx/deltas/delayed_delta/tasks.rb +0 -23
- data/lib/thinking_sphinx/deltas/delayed_delta/version.rb +0 -5
- data/spec/thinking_sphinx/deltas/delayed_delta/delta_job_spec.rb +0 -53
- data/spec/thinking_sphinx/deltas/delayed_delta/flag_as_deleted_job_spec.rb +0 -78
- data/spec/thinking_sphinx/deltas/delayed_delta/job_spec.rb +0 -52
- data/spec/thinking_sphinx/deltas/delayed_delta_spec.rb +0 -128
- data/tasks/rails.rake +0 -1
@@ -1,128 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe ThinkingSphinx::Deltas::DelayedDelta do
|
4
|
-
describe '#index' do
|
5
|
-
before :each do
|
6
|
-
ThinkingSphinx.updates_enabled = true
|
7
|
-
ThinkingSphinx.deltas_enabled = true
|
8
|
-
ThinkingSphinx::Configuration.instance.delayed_job_priority = 2
|
9
|
-
|
10
|
-
ThinkingSphinx::Deltas::Job.stub!(:enqueue => true)
|
11
|
-
Delayed::Job.stub!(:enqueue => true, :inspect => "Delayed::Job")
|
12
|
-
|
13
|
-
@delayed_delta = ThinkingSphinx::Deltas::DelayedDelta.new(
|
14
|
-
stub('instance'), {}
|
15
|
-
)
|
16
|
-
@delayed_delta.stub!(:toggled => true)
|
17
|
-
|
18
|
-
@model = stub('foo')
|
19
|
-
@model.stub!(:name => 'foo')
|
20
|
-
@model.stub!(:source_of_sphinx_index => @model)
|
21
|
-
@model.stub!(:core_index_names => ['foo_core'])
|
22
|
-
@model.stub!(:delta_index_names => ['foo_delta'])
|
23
|
-
|
24
|
-
@instance = stub('instance')
|
25
|
-
@instance.stub!(:sphinx_document_id => 42)
|
26
|
-
end
|
27
|
-
|
28
|
-
context 'updates disabled' do
|
29
|
-
before :each do
|
30
|
-
ThinkingSphinx.updates_enabled = false
|
31
|
-
end
|
32
|
-
|
33
|
-
it "should not enqueue a delta job" do
|
34
|
-
ThinkingSphinx::Deltas::Job.should_not_receive(:enqueue)
|
35
|
-
|
36
|
-
@delayed_delta.index(@model)
|
37
|
-
end
|
38
|
-
|
39
|
-
it "should not enqueue a flag as deleted job" do
|
40
|
-
Delayed::Job.should_not_receive(:enqueue)
|
41
|
-
|
42
|
-
@delayed_delta.index(@model)
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
context 'deltas disabled' do
|
47
|
-
before :each do
|
48
|
-
ThinkingSphinx.deltas_enabled = false
|
49
|
-
end
|
50
|
-
|
51
|
-
it "should not enqueue a delta job" do
|
52
|
-
ThinkingSphinx::Deltas::Job.should_not_receive(:enqueue)
|
53
|
-
|
54
|
-
@delayed_delta.index(@model)
|
55
|
-
end
|
56
|
-
|
57
|
-
it "should not enqueue a flag as deleted job" do
|
58
|
-
Delayed::Job.should_not_receive(:enqueue)
|
59
|
-
|
60
|
-
@delayed_delta.index(@model)
|
61
|
-
end
|
62
|
-
end
|
63
|
-
|
64
|
-
context "instance isn't toggled" do
|
65
|
-
before :each do
|
66
|
-
@delayed_delta.stub!(:toggled => false)
|
67
|
-
end
|
68
|
-
|
69
|
-
it "should not enqueue a delta job" do
|
70
|
-
ThinkingSphinx::Deltas::Job.should_not_receive(:enqueue)
|
71
|
-
|
72
|
-
@delayed_delta.index(@model, @instance)
|
73
|
-
end
|
74
|
-
|
75
|
-
it "should not enqueue a flag as deleted job" do
|
76
|
-
Delayed::Job.should_not_receive(:enqueue)
|
77
|
-
|
78
|
-
@delayed_delta.index(@model, @instance)
|
79
|
-
end
|
80
|
-
end
|
81
|
-
|
82
|
-
it "should enqueue a delta job for the appropriate indices" do
|
83
|
-
ThinkingSphinx::Deltas::Job.should_receive(:enqueue) do |job, priority|
|
84
|
-
job.indices.should == ['foo_delta']
|
85
|
-
end
|
86
|
-
|
87
|
-
@delayed_delta.index(@model)
|
88
|
-
end
|
89
|
-
|
90
|
-
it "should use the defined priority for the delta job" do
|
91
|
-
ThinkingSphinx::Deltas::Job.should_receive(:enqueue) do |job, priority|
|
92
|
-
priority.should == 2
|
93
|
-
end
|
94
|
-
|
95
|
-
@delayed_delta.index(@model)
|
96
|
-
end
|
97
|
-
|
98
|
-
it "should enqueue a flag-as-deleted job for the appropriate indices" do
|
99
|
-
Delayed::Job.should_receive(:enqueue) do |job, options|
|
100
|
-
job.indices.should == ['foo_core']
|
101
|
-
end
|
102
|
-
|
103
|
-
@delayed_delta.index(@model, @instance)
|
104
|
-
end
|
105
|
-
|
106
|
-
it "should enqueue a flag-as-deleted job for the appropriate id" do
|
107
|
-
Delayed::Job.should_receive(:enqueue) do |job, options|
|
108
|
-
job.document_id.should == 42
|
109
|
-
end
|
110
|
-
|
111
|
-
@delayed_delta.index(@model, @instance)
|
112
|
-
end
|
113
|
-
|
114
|
-
it "should use the defined priority for the flag-as-deleted job" do
|
115
|
-
Delayed::Job.should_receive(:enqueue) do |job, options|
|
116
|
-
options[:priority].should == 2
|
117
|
-
end
|
118
|
-
|
119
|
-
@delayed_delta.index(@model, @instance)
|
120
|
-
end
|
121
|
-
|
122
|
-
it "should not enqueue a flag-as-deleted job if no instance is provided" do
|
123
|
-
Delayed::Job.should_not_receive(:enqueue)
|
124
|
-
|
125
|
-
@delayed_delta.index(@model)
|
126
|
-
end
|
127
|
-
end
|
128
|
-
end
|
data/tasks/rails.rake
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
require File.join(File.dirname(__FILE__), '/../lib/thinking_sphinx/deltas/delayed_delta/tasks')
|