chewy 0.7.0 → 0.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +2 -0
- data/.rspec +0 -1
- data/.travis.yml +2 -2
- data/Appraisals +6 -2
- data/CHANGELOG.md +29 -1
- data/Gemfile +4 -0
- data/README.md +137 -19
- data/chewy.gemspec +1 -0
- data/gemfiles/rails.3.2.activerecord.gemfile +2 -0
- data/gemfiles/rails.3.2.activerecord.kaminari.gemfile +1 -1
- data/gemfiles/rails.4.0.activerecord.gemfile +2 -0
- data/gemfiles/rails.4.0.activerecord.kaminari.gemfile +1 -1
- data/gemfiles/rails.4.0.mongoid.gemfile +2 -0
- data/gemfiles/rails.4.0.mongoid.kaminari.gemfile +1 -1
- data/gemfiles/rails.4.1.activerecord.gemfile +2 -0
- data/gemfiles/rails.4.1.activerecord.kaminari.gemfile +1 -1
- data/gemfiles/rails.4.1.mongoid.gemfile +2 -0
- data/gemfiles/rails.4.1.mongoid.kaminari.gemfile +1 -1
- data/gemfiles/rails.4.2.activerecord.gemfile +2 -0
- data/gemfiles/rails.4.2.activerecord.kaminari.gemfile +1 -1
- data/gemfiles/rails.4.2.mongoid.gemfile +2 -0
- data/gemfiles/rails.4.2.mongoid.kaminari.gemfile +1 -1
- data/lib/chewy.rb +1 -2
- data/lib/chewy/config.rb +3 -3
- data/lib/chewy/fields/base.rb +27 -30
- data/lib/chewy/fields/root.rb +9 -19
- data/lib/chewy/query.rb +34 -1
- data/lib/chewy/railtie.rb +1 -0
- data/lib/chewy/rspec/update_index.rb +16 -6
- data/lib/chewy/strategy.rb +12 -0
- data/lib/chewy/strategy/atomic.rb +1 -1
- data/lib/chewy/strategy/resque.rb +26 -0
- data/lib/chewy/strategy/sidekiq.rb +26 -0
- data/lib/chewy/strategy/urgent.rb +1 -1
- data/lib/chewy/type.rb +2 -0
- data/lib/chewy/type/adapter/active_record.rb +7 -3
- data/lib/chewy/type/adapter/mongoid.rb +5 -0
- data/lib/chewy/type/adapter/orm.rb +1 -1
- data/lib/chewy/type/crutch.rb +31 -0
- data/lib/chewy/type/import.rb +7 -6
- data/lib/chewy/type/mapping.rb +7 -3
- data/lib/chewy/type/observe.rb +24 -35
- data/lib/chewy/version.rb +1 -1
- data/spec/chewy/fields/base_spec.rb +26 -19
- data/spec/chewy/query_spec.rb +13 -0
- data/spec/chewy/runtime_spec.rb +1 -1
- data/spec/chewy/strategy/resque_spec.rb +35 -0
- data/spec/chewy/strategy/sidekiq_spec.rb +35 -0
- data/spec/chewy/type/adapter/mongoid_spec.rb +18 -9
- data/spec/chewy/type/mapping_spec.rb +14 -9
- data/spec/chewy/type/observe_spec.rb +22 -7
- data/spec/spec_helper.rb +1 -0
- metadata +23 -2
@@ -20,14 +20,17 @@ describe Chewy::Type::Mapping do
|
|
20
20
|
end
|
21
21
|
|
22
22
|
describe '.field' do
|
23
|
-
specify { expect(product.root_object.
|
24
|
-
specify { expect(product.root_object.
|
23
|
+
specify { expect(product.root_object.children.map(&:name)).to eq([:name, :surname, :title, :price]) }
|
24
|
+
specify { expect(product.root_object.children.map(&:parent)).to eq([product.root_object] * 4) }
|
25
25
|
|
26
|
-
specify { expect(product.root_object.
|
27
|
-
specify { expect(product.root_object.
|
26
|
+
specify { expect(product.root_object.children[0].children.map(&:name)).to eq([]) }
|
27
|
+
specify { expect(product.root_object.children[1].children.map(&:name)).to eq([]) }
|
28
28
|
|
29
|
-
specify { expect(product.root_object.
|
30
|
-
specify { expect(product.root_object.
|
29
|
+
specify { expect(product.root_object.children[2].children.map(&:name)).to eq([:subfield1]) }
|
30
|
+
specify { expect(product.root_object.children[2].children.map(&:parent)).to eq([product.root_object.children[2]]) }
|
31
|
+
|
32
|
+
specify { expect(product.root_object.children[3].children.map(&:name)).to eq([:subfield2]) }
|
33
|
+
specify { expect(product.root_object.children[3].children.map(&:parent)).to eq([product.root_object.children[3]]) }
|
31
34
|
end
|
32
35
|
|
33
36
|
describe '.mappings_hash' do
|
@@ -60,7 +63,7 @@ describe Chewy::Type::Mapping do
|
|
60
63
|
end
|
61
64
|
end
|
62
65
|
|
63
|
-
specify { expect(product.mappings_hash[:product][:_parent]).to eq({
|
66
|
+
specify { expect(product.mappings_hash[:product][:_parent]).to eq({ type: 'project' }) }
|
64
67
|
end
|
65
68
|
end
|
66
69
|
end
|
@@ -76,7 +79,9 @@ describe Chewy::Type::Mapping do
|
|
76
79
|
end
|
77
80
|
end
|
78
81
|
|
79
|
-
specify { expect(product.root_object.
|
80
|
-
specify { expect(product.root_object.
|
82
|
+
specify { expect(product.root_object.children.map(&:name)).to eq([:title]) }
|
83
|
+
specify { expect(product.root_object.children.map(&:parent)).to eq([product.root_object]) }
|
84
|
+
specify { expect(product.root_object.children[0].children.map(&:name)).to eq([:subfield1]) }
|
85
|
+
specify { expect(product.root_object.children[0].children.map(&:parent)).to eq([product.root_object.children[0]]) }
|
81
86
|
end
|
82
87
|
end
|
@@ -22,7 +22,9 @@ describe Chewy::Type::Import do
|
|
22
22
|
before do
|
23
23
|
stub_model(:city) do
|
24
24
|
update_index('cities#city') { self }
|
25
|
-
update_index 'countries#country'
|
25
|
+
update_index 'countries#country' do
|
26
|
+
changes['country_id'] || previous_changes['country_id'] || country
|
27
|
+
end
|
26
28
|
end
|
27
29
|
|
28
30
|
stub_model(:country) do
|
@@ -42,14 +44,27 @@ describe Chewy::Type::Import do
|
|
42
44
|
end
|
43
45
|
end
|
44
46
|
|
45
|
-
|
46
|
-
|
47
|
+
context do
|
48
|
+
let!(:country1) { Chewy.strategy(:atomic) { Country.create!(id: 1) } }
|
49
|
+
let!(:country2) { Chewy.strategy(:atomic) { Country.create!(id: 2) } }
|
50
|
+
let!(:city) { Chewy.strategy(:atomic) { City.create!(id: 1, country: country1) } }
|
51
|
+
|
52
|
+
specify { expect { city.save! }.to update_index('cities#city').and_reindex(city) }
|
53
|
+
specify { expect { city.save! }.to update_index('countries#country').and_reindex(country1) }
|
54
|
+
|
55
|
+
specify { expect { city.update_attributes!(country: nil) }.to update_index('cities#city').and_reindex(city) }
|
56
|
+
specify { expect { city.update_attributes!(country: nil) }.to update_index('countries#country').and_reindex(country1) }
|
47
57
|
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
58
|
+
specify { expect { city.update_attributes!(country: country2) }.to update_index('cities#city').and_reindex(city) }
|
59
|
+
specify { expect { city.update_attributes!(country: country2) }.to update_index('countries#country').and_reindex(country1, country2) }
|
60
|
+
end
|
61
|
+
|
62
|
+
context do
|
63
|
+
let!(:country) { Chewy.strategy(:atomic) { Country.create!(id: 1, cities: 2.times.map { |i| City.create!(id: i) }) } }
|
52
64
|
|
65
|
+
specify { expect { country.save! }.to update_index('cities#city').and_reindex(country.cities) }
|
66
|
+
specify { expect { country.save! }.to update_index('countries#country').and_reindex(country) }
|
67
|
+
end
|
53
68
|
end
|
54
69
|
|
55
70
|
context 'transactions', :active_record do
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: chewy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.8.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- pyromaniac
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-05-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -122,6 +122,20 @@ dependencies:
|
|
122
122
|
- - ">="
|
123
123
|
- !ruby/object:Gem::Version
|
124
124
|
version: '0'
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: resque_spec
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - ">="
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '0'
|
132
|
+
type: :development
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - ">="
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '0'
|
125
139
|
- !ruby/object:Gem::Dependency
|
126
140
|
name: activesupport
|
127
141
|
requirement: !ruby/object:Gem::Requirement
|
@@ -243,6 +257,8 @@ files:
|
|
243
257
|
- lib/chewy/strategy/atomic.rb
|
244
258
|
- lib/chewy/strategy/base.rb
|
245
259
|
- lib/chewy/strategy/bypass.rb
|
260
|
+
- lib/chewy/strategy/resque.rb
|
261
|
+
- lib/chewy/strategy/sidekiq.rb
|
246
262
|
- lib/chewy/strategy/urgent.rb
|
247
263
|
- lib/chewy/type.rb
|
248
264
|
- lib/chewy/type/actions.rb
|
@@ -251,6 +267,7 @@ files:
|
|
251
267
|
- lib/chewy/type/adapter/mongoid.rb
|
252
268
|
- lib/chewy/type/adapter/object.rb
|
253
269
|
- lib/chewy/type/adapter/orm.rb
|
270
|
+
- lib/chewy/type/crutch.rb
|
254
271
|
- lib/chewy/type/import.rb
|
255
272
|
- lib/chewy/type/mapping.rb
|
256
273
|
- lib/chewy/type/observe.rb
|
@@ -295,6 +312,8 @@ files:
|
|
295
312
|
- spec/chewy/runtime/version_spec.rb
|
296
313
|
- spec/chewy/runtime_spec.rb
|
297
314
|
- spec/chewy/search_spec.rb
|
315
|
+
- spec/chewy/strategy/resque_spec.rb
|
316
|
+
- spec/chewy/strategy/sidekiq_spec.rb
|
298
317
|
- spec/chewy/strategy_spec.rb
|
299
318
|
- spec/chewy/type/actions_spec.rb
|
300
319
|
- spec/chewy/type/adapter/active_record_spec.rb
|
@@ -372,6 +391,8 @@ test_files:
|
|
372
391
|
- spec/chewy/runtime/version_spec.rb
|
373
392
|
- spec/chewy/runtime_spec.rb
|
374
393
|
- spec/chewy/search_spec.rb
|
394
|
+
- spec/chewy/strategy/resque_spec.rb
|
395
|
+
- spec/chewy/strategy/sidekiq_spec.rb
|
375
396
|
- spec/chewy/strategy_spec.rb
|
376
397
|
- spec/chewy/type/actions_spec.rb
|
377
398
|
- spec/chewy/type/adapter/active_record_spec.rb
|