chewy 0.5.0 → 0.5.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +2 -2
- data/CHANGELOG.md +24 -0
- data/Guardfile +1 -2
- data/README.md +23 -4
- data/chewy.gemspec +3 -1
- data/lib/chewy.rb +1 -0
- data/lib/chewy/fields/base.rb +1 -1
- data/lib/chewy/fields/root.rb +13 -0
- data/lib/chewy/index/search.rb +1 -1
- data/lib/chewy/query.rb +247 -8
- data/lib/chewy/query/criteria.rb +33 -1
- data/lib/chewy/railtie.rb +5 -0
- data/lib/chewy/rspec/update_index.rb +16 -9
- data/lib/chewy/type/actions.rb +19 -0
- data/lib/chewy/type/adapter/active_record.rb +1 -1
- data/lib/chewy/type/base.rb +2 -0
- data/lib/chewy/type/import.rb +44 -8
- data/lib/chewy/version.rb +1 -1
- data/lib/generators/chewy/install_generator.rb +11 -0
- data/lib/generators/templates/chewy.yml +7 -0
- data/lib/tasks/chewy.rake +1 -1
- data/spec/chewy/config_spec.rb +3 -3
- data/spec/chewy/index/actions_spec.rb +53 -53
- data/spec/chewy/query/criteria_spec.rb +58 -10
- data/spec/chewy/query_spec.rb +102 -2
- data/spec/chewy/runtime_spec.rb +1 -1
- data/spec/chewy/type/actions_spec.rb +28 -0
- data/spec/chewy/type/adapter/active_record_spec.rb +29 -28
- data/spec/chewy/type/adapter/object_spec.rb +9 -9
- data/spec/chewy/type/import_spec.rb +87 -10
- data/spec/chewy/type/mapping_spec.rb +30 -0
- data/spec/spec_helper.rb +2 -1
- metadata +37 -4
@@ -33,6 +33,36 @@ describe Chewy::Type::Mapping do
|
|
33
33
|
describe '.mappings_hash' do
|
34
34
|
specify { Class.new(Chewy::Type::Base).mappings_hash.should == {} }
|
35
35
|
specify { product.mappings_hash.should == product.root_object.mappings_hash }
|
36
|
+
|
37
|
+
context 'parent-child relationship' do
|
38
|
+
context do
|
39
|
+
before do
|
40
|
+
stub_index(:products) do
|
41
|
+
define_type :product do
|
42
|
+
root _parent: 'project', parent_id: -> { project_id } do
|
43
|
+
field :name, 'surname'
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
specify { product.mappings_hash[:product][:_parent].should == { type: 'project' } }
|
50
|
+
end
|
51
|
+
|
52
|
+
context do
|
53
|
+
before do
|
54
|
+
stub_index(:products) do
|
55
|
+
define_type :product do
|
56
|
+
root parent: {'type' => 'project'}, parent_id: -> { project_id } do
|
57
|
+
field :name, 'surname'
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
specify { product.mappings_hash[:product][:_parent].should == { 'type' => 'project' } }
|
64
|
+
end
|
65
|
+
end
|
36
66
|
end
|
37
67
|
|
38
68
|
context "no root element call" 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.5.
|
4
|
+
version: 0.5.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- pyromaniac
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-09-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -30,14 +30,42 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - ~>
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version:
|
33
|
+
version: 3.0.0
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - ~>
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version:
|
40
|
+
version: 3.0.0
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec-its
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ~>
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 1.0.1
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ~>
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 1.0.1
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rspec-collection_matchers
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - '>='
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
41
69
|
- !ruby/object:Gem::Dependency
|
42
70
|
name: sqlite3
|
43
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -188,6 +216,7 @@ files:
|
|
188
216
|
- lib/chewy/runtime.rb
|
189
217
|
- lib/chewy/runtime/version.rb
|
190
218
|
- lib/chewy/type.rb
|
219
|
+
- lib/chewy/type/actions.rb
|
191
220
|
- lib/chewy/type/adapter/active_record.rb
|
192
221
|
- lib/chewy/type/adapter/base.rb
|
193
222
|
- lib/chewy/type/adapter/object.rb
|
@@ -197,6 +226,8 @@ files:
|
|
197
226
|
- lib/chewy/type/observe.rb
|
198
227
|
- lib/chewy/type/wrapper.rb
|
199
228
|
- lib/chewy/version.rb
|
229
|
+
- lib/generators/chewy/install_generator.rb
|
230
|
+
- lib/generators/templates/chewy.yml
|
200
231
|
- lib/tasks/chewy.rake
|
201
232
|
- spec/chewy/config_spec.rb
|
202
233
|
- spec/chewy/fields/base_spec.rb
|
@@ -231,6 +262,7 @@ files:
|
|
231
262
|
- spec/chewy/rspec/update_index_spec.rb
|
232
263
|
- spec/chewy/runtime/version_spec.rb
|
233
264
|
- spec/chewy/runtime_spec.rb
|
265
|
+
- spec/chewy/type/actions_spec.rb
|
234
266
|
- spec/chewy/type/adapter/active_record_spec.rb
|
235
267
|
- spec/chewy/type/adapter/object_spec.rb
|
236
268
|
- spec/chewy/type/import_spec.rb
|
@@ -300,6 +332,7 @@ test_files:
|
|
300
332
|
- spec/chewy/rspec/update_index_spec.rb
|
301
333
|
- spec/chewy/runtime/version_spec.rb
|
302
334
|
- spec/chewy/runtime_spec.rb
|
335
|
+
- spec/chewy/type/actions_spec.rb
|
303
336
|
- spec/chewy/type/adapter/active_record_spec.rb
|
304
337
|
- spec/chewy/type/adapter/object_spec.rb
|
305
338
|
- spec/chewy/type/import_spec.rb
|