chewy 0.10.1 → 7.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.circleci/config.yml +240 -0
- data/.github/ISSUE_TEMPLATE/bug_report.md +39 -0
- data/.github/ISSUE_TEMPLATE/feature_request.md +20 -0
- data/.github/PULL_REQUEST_TEMPLATE.md +16 -0
- data/.rubocop.yml +25 -25
- data/Appraisals +12 -10
- data/CHANGELOG.md +312 -331
- data/CODE_OF_CONDUCT.md +14 -0
- data/CONTRIBUTING.md +63 -0
- data/Gemfile +5 -1
- data/LICENSE.txt +1 -1
- data/README.md +143 -77
- data/chewy.gemspec +10 -12
- data/gemfiles/{rails.4.2.mongoid.5.1.gemfile → rails.5.2.activerecord.gemfile} +6 -4
- data/gemfiles/{rails.4.2.activerecord.gemfile → rails.5.2.mongoid.6.4.gemfile} +6 -4
- data/gemfiles/{rails.4.0.activerecord.gemfile → rails.6.0.activerecord.gemfile} +6 -3
- data/gemfiles/rails.6.1.activerecord.gemfile +19 -0
- data/gemfiles/sequel.4.45.gemfile +2 -2
- data/lib/chewy.rb +2 -1
- data/lib/chewy/backports/duplicable.rb +1 -1
- data/lib/chewy/config.rb +10 -39
- data/lib/chewy/fields/base.rb +9 -3
- data/lib/chewy/fields/root.rb +13 -9
- data/lib/chewy/index.rb +3 -1
- data/lib/chewy/index/actions.rb +28 -16
- data/lib/chewy/index/aliases.rb +16 -5
- data/lib/chewy/index/settings.rb +2 -0
- data/lib/chewy/index/specification.rb +12 -10
- data/lib/chewy/minitest/helpers.rb +6 -6
- data/lib/chewy/minitest/search_index_receiver.rb +17 -17
- data/lib/chewy/multi_search.rb +62 -0
- data/lib/chewy/railtie.rb +3 -5
- data/lib/chewy/rake_helper.rb +5 -5
- data/lib/chewy/rspec/update_index.rb +3 -5
- data/lib/chewy/search.rb +4 -11
- data/lib/chewy/search/loader.rb +1 -1
- data/lib/chewy/search/pagination/will_paginate.rb +1 -1
- data/lib/chewy/search/parameters.rb +24 -6
- data/lib/chewy/search/parameters/allow_partial_search_results.rb +27 -0
- data/lib/chewy/search/parameters/concerns/query_storage.rb +4 -3
- data/lib/chewy/search/parameters/indices.rb +123 -0
- data/lib/chewy/search/parameters/none.rb +1 -3
- data/lib/chewy/search/request.rb +101 -74
- data/lib/chewy/search/scrolling.rb +7 -6
- data/lib/chewy/stash.rb +31 -22
- data/lib/chewy/strategy/active_job.rb +1 -1
- data/lib/chewy/strategy/atomic.rb +1 -1
- data/lib/chewy/strategy/sidekiq.rb +1 -1
- data/lib/chewy/type.rb +5 -2
- data/lib/chewy/type/adapter/active_record.rb +1 -1
- data/lib/chewy/type/adapter/base.rb +9 -9
- data/lib/chewy/type/adapter/mongoid.rb +2 -4
- data/lib/chewy/type/adapter/orm.rb +7 -4
- data/lib/chewy/type/adapter/sequel.rb +5 -7
- data/lib/chewy/type/crutch.rb +1 -1
- data/lib/chewy/type/import.rb +16 -5
- data/lib/chewy/type/import/bulk_builder.rb +1 -1
- data/lib/chewy/type/import/bulk_request.rb +4 -2
- data/lib/chewy/type/import/journal_builder.rb +3 -3
- data/lib/chewy/type/import/routine.rb +3 -3
- data/lib/chewy/type/mapping.rb +42 -36
- data/lib/chewy/type/observe.rb +16 -12
- data/lib/chewy/type/syncer.rb +6 -7
- data/lib/chewy/type/witchcraft.rb +5 -3
- data/lib/chewy/type/wrapper.rb +14 -4
- data/lib/chewy/version.rb +1 -1
- data/lib/sequel/plugins/chewy_observe.rb +4 -19
- data/migration_guide.md +34 -0
- data/spec/chewy/config_spec.rb +16 -21
- data/spec/chewy/fields/base_spec.rb +68 -70
- data/spec/chewy/fields/root_spec.rb +13 -13
- data/spec/chewy/index/actions_spec.rb +157 -38
- data/spec/chewy/index/aliases_spec.rb +3 -3
- data/spec/chewy/index/specification_spec.rb +25 -16
- data/spec/chewy/index_spec.rb +75 -45
- data/spec/chewy/journal_spec.rb +33 -29
- data/spec/chewy/minitest/search_index_receiver_spec.rb +11 -9
- data/spec/chewy/multi_search_spec.rb +85 -0
- data/spec/chewy/rake_helper_spec.rb +123 -95
- data/spec/chewy/rspec/update_index_spec.rb +47 -46
- data/spec/chewy/runtime_spec.rb +2 -2
- data/spec/chewy/search/parameters/indices_spec.rb +190 -0
- data/spec/chewy/search/parameters/none_spec.rb +1 -1
- data/spec/chewy/search/parameters_spec.rb +21 -4
- data/spec/chewy/search/request_spec.rb +103 -70
- data/spec/chewy/search/response_spec.rb +27 -17
- data/spec/chewy/search/scrolling_spec.rb +27 -17
- data/spec/chewy/search_spec.rb +49 -35
- data/spec/chewy/stash_spec.rb +15 -13
- data/spec/chewy/strategy/active_job_spec.rb +15 -2
- data/spec/chewy/strategy/shoryuken_spec.rb +8 -2
- data/spec/chewy/strategy/sidekiq_spec.rb +6 -2
- data/spec/chewy/type/adapter/active_record_spec.rb +16 -4
- data/spec/chewy/type/import/bulk_builder_spec.rb +9 -94
- data/spec/chewy/type/import/journal_builder_spec.rb +17 -15
- data/spec/chewy/type/import_spec.rb +15 -0
- data/spec/chewy/type/mapping_spec.rb +51 -18
- data/spec/chewy/type/observe_spec.rb +4 -4
- data/spec/chewy/type/witchcraft_spec.rb +15 -0
- data/spec/chewy/type/wrapper_spec.rb +3 -1
- data/spec/chewy_spec.rb +0 -7
- data/spec/spec_helper.rb +5 -1
- data/spec/support/active_record.rb +21 -0
- metadata +51 -116
- data/.travis.yml +0 -53
- data/LEGACY_DSL.md +0 -497
- data/gemfiles/rails.4.1.activerecord.gemfile +0 -14
- data/gemfiles/rails.5.0.activerecord.gemfile +0 -15
- data/gemfiles/rails.5.0.mongoid.6.0.gemfile +0 -15
- data/gemfiles/rails.5.1.activerecord.gemfile +0 -15
- data/gemfiles/rails.5.1.mongoid.6.1.gemfile +0 -15
- data/lib/chewy/query.rb +0 -1098
- data/lib/chewy/query/compose.rb +0 -68
- data/lib/chewy/query/criteria.rb +0 -191
- data/lib/chewy/query/filters.rb +0 -227
- data/lib/chewy/query/loading.rb +0 -111
- data/lib/chewy/query/nodes/and.rb +0 -25
- data/lib/chewy/query/nodes/base.rb +0 -17
- data/lib/chewy/query/nodes/bool.rb +0 -34
- data/lib/chewy/query/nodes/equal.rb +0 -34
- data/lib/chewy/query/nodes/exists.rb +0 -20
- data/lib/chewy/query/nodes/expr.rb +0 -28
- data/lib/chewy/query/nodes/field.rb +0 -110
- data/lib/chewy/query/nodes/has_child.rb +0 -15
- data/lib/chewy/query/nodes/has_parent.rb +0 -15
- data/lib/chewy/query/nodes/has_relation.rb +0 -59
- data/lib/chewy/query/nodes/match_all.rb +0 -11
- data/lib/chewy/query/nodes/missing.rb +0 -20
- data/lib/chewy/query/nodes/not.rb +0 -25
- data/lib/chewy/query/nodes/or.rb +0 -25
- data/lib/chewy/query/nodes/prefix.rb +0 -19
- data/lib/chewy/query/nodes/query.rb +0 -20
- data/lib/chewy/query/nodes/range.rb +0 -63
- data/lib/chewy/query/nodes/raw.rb +0 -15
- data/lib/chewy/query/nodes/regexp.rb +0 -35
- data/lib/chewy/query/nodes/script.rb +0 -20
- data/lib/chewy/query/pagination.rb +0 -25
- data/spec/chewy/query/criteria_spec.rb +0 -700
- data/spec/chewy/query/filters_spec.rb +0 -201
- data/spec/chewy/query/loading_spec.rb +0 -124
- data/spec/chewy/query/nodes/and_spec.rb +0 -12
- data/spec/chewy/query/nodes/bool_spec.rb +0 -14
- data/spec/chewy/query/nodes/equal_spec.rb +0 -32
- data/spec/chewy/query/nodes/exists_spec.rb +0 -18
- data/spec/chewy/query/nodes/has_child_spec.rb +0 -59
- data/spec/chewy/query/nodes/has_parent_spec.rb +0 -59
- data/spec/chewy/query/nodes/match_all_spec.rb +0 -11
- data/spec/chewy/query/nodes/missing_spec.rb +0 -16
- data/spec/chewy/query/nodes/not_spec.rb +0 -13
- data/spec/chewy/query/nodes/or_spec.rb +0 -12
- data/spec/chewy/query/nodes/prefix_spec.rb +0 -16
- data/spec/chewy/query/nodes/query_spec.rb +0 -12
- data/spec/chewy/query/nodes/range_spec.rb +0 -32
- data/spec/chewy/query/nodes/raw_spec.rb +0 -11
- data/spec/chewy/query/nodes/regexp_spec.rb +0 -43
- data/spec/chewy/query/nodes/script_spec.rb +0 -15
- data/spec/chewy/query/pagination/kaminari_spec.rb +0 -5
- data/spec/chewy/query/pagination/will_paginate_spec.rb +0 -5
- data/spec/chewy/query/pagination_spec.rb +0 -39
- data/spec/chewy/query_spec.rb +0 -636
- data/spec/chewy/search/parameters/indices_boost_spec.rb +0 -83
@@ -4,7 +4,9 @@ describe :update_index do
|
|
4
4
|
before do
|
5
5
|
stub_index(:dummies) do
|
6
6
|
define_type :dummy
|
7
|
-
|
7
|
+
end
|
8
|
+
stub_index(:dummies2) do
|
9
|
+
define_type :dummy
|
8
10
|
end
|
9
11
|
end
|
10
12
|
|
@@ -13,19 +15,18 @@ describe :update_index do
|
|
13
15
|
DummiesIndex.create!
|
14
16
|
end
|
15
17
|
|
16
|
-
specify { expect {}.not_to update_index(DummiesIndex
|
17
|
-
specify { expect { DummiesIndex::Dummy.bulk body: [] }.not_to update_index(DummiesIndex
|
18
|
+
specify { expect {}.not_to update_index(DummiesIndex) }
|
19
|
+
specify { expect { DummiesIndex::Dummy.bulk body: [] }.not_to update_index(DummiesIndex) }
|
18
20
|
|
19
21
|
specify do
|
20
|
-
expect { expect { DummiesIndex::Dummy.bulk body: [{index: {_id: 42}}] }.not_to update_index(DummiesIndex
|
22
|
+
expect { expect { DummiesIndex::Dummy.bulk body: [{index: {_id: 42}}] }.not_to update_index(DummiesIndex) }
|
21
23
|
.to fail_with(/Expected index .* not to be updated, but it was with/)
|
22
24
|
end
|
23
25
|
|
24
26
|
specify do
|
25
27
|
expect do
|
26
28
|
DummiesIndex::Dummy.bulk body: [{index: {_id: 42, data: {}}}, {index: {_id: 41, data: {}}}]
|
27
|
-
|
28
|
-
end.to update_index(DummiesIndex::Dummy).and_reindex(41, 42).only
|
29
|
+
end.to update_index(DummiesIndex).and_reindex(41, 42).only
|
29
30
|
end
|
30
31
|
|
31
32
|
context do
|
@@ -33,7 +34,7 @@ describe :update_index do
|
|
33
34
|
expect do
|
34
35
|
expect do
|
35
36
|
DummiesIndex::Dummy.bulk body: [{index: {_id: 42}}, {index: {_id: 41}}, {index: {_id: 42}}]
|
36
|
-
end.not_to update_index(DummiesIndex
|
37
|
+
end.not_to update_index(DummiesIndex)
|
37
38
|
end
|
38
39
|
end
|
39
40
|
|
@@ -45,60 +46,60 @@ describe :update_index do
|
|
45
46
|
specify do
|
46
47
|
expect do
|
47
48
|
DummiesIndex::Dummy.bulk body: [{index: {_id: 42, data: {}}}, {index: {_id: 41, data: {}}}]
|
48
|
-
|
49
|
-
end.to update_index(DummiesIndex
|
50
|
-
.and update_index(
|
49
|
+
Dummies2Index::Dummy.bulk body: [{index: {_id: 43, data: {}}}]
|
50
|
+
end.to update_index(DummiesIndex).and_reindex(41, 42).only
|
51
|
+
.and update_index(Dummies2Index).and_reindex(43).only
|
51
52
|
end
|
52
53
|
|
53
54
|
context do
|
54
55
|
let(:expectation) do
|
55
56
|
expect do
|
56
57
|
expect do
|
57
|
-
|
58
|
-
end.to update_index(DummiesIndex
|
59
|
-
.and update_index(
|
58
|
+
Dummies2Index::Dummy.bulk body: [{index: {_id: 43, data: {}}}]
|
59
|
+
end.to update_index(DummiesIndex).and_reindex(41, 42).only
|
60
|
+
.and update_index(Dummies2Index).and_reindex(43).only
|
60
61
|
end
|
61
62
|
end
|
62
63
|
|
63
|
-
specify { expectation.to fail_matching 'Expected index `DummiesIndex
|
64
|
+
specify { expectation.to fail_matching 'Expected index `DummiesIndex` to be updated' }
|
64
65
|
end
|
65
66
|
end
|
66
67
|
|
67
68
|
context '#only' do
|
68
69
|
specify do
|
69
70
|
expect { DummiesIndex::Dummy.bulk body: [{index: {_id: 42, data: {}}}, {index: {_id: 41, data: {}}}] }
|
70
|
-
.to update_index(DummiesIndex
|
71
|
+
.to update_index(DummiesIndex).and_reindex(41, 42).only
|
71
72
|
end
|
72
73
|
specify do
|
73
74
|
expect do
|
74
75
|
expect { DummiesIndex::Dummy.bulk body: [{index: {_id: 42, data: {}}}, {index: {_id: 41, data: {}}}] }
|
75
|
-
.to update_index(DummiesIndex
|
76
|
+
.to update_index(DummiesIndex).and_reindex(41).only
|
76
77
|
end
|
77
78
|
.to fail_matching 'to update documents ["41"] only, but ["42"] was updated also'
|
78
79
|
end
|
79
80
|
specify do
|
80
81
|
expect do
|
81
82
|
expect { DummiesIndex::Dummy.bulk body: [{index: {_id: 42, data: {}}}, {index: {_id: 41, data: {}}}] }
|
82
|
-
.to update_index(DummiesIndex
|
83
|
+
.to update_index(DummiesIndex).and_reindex(41, times: 2).only
|
83
84
|
end
|
84
85
|
.to fail_matching 'to update documents ["41"] only, but ["42"] was updated also'
|
85
86
|
end
|
86
87
|
|
87
88
|
specify do
|
88
89
|
expect { DummiesIndex::Dummy.bulk body: [{delete: {_id: 42}}, {delete: {_id: 41}}] }
|
89
|
-
.to update_index(DummiesIndex
|
90
|
+
.to update_index(DummiesIndex).and_delete(41, 42).only
|
90
91
|
end
|
91
92
|
specify do
|
92
93
|
expect do
|
93
94
|
expect { DummiesIndex::Dummy.bulk body: [{delete: {_id: 42}}, {delete: {_id: 41}}] }
|
94
|
-
.to update_index(DummiesIndex
|
95
|
+
.to update_index(DummiesIndex).and_delete(41).only
|
95
96
|
end
|
96
97
|
.to fail_matching 'to delete documents ["41"] only, but ["42"] was deleted also'
|
97
98
|
end
|
98
99
|
specify do
|
99
100
|
expect do
|
100
101
|
expect { DummiesIndex::Dummy.bulk body: [{delete: {_id: 42}}, {delete: {_id: 41}}] }
|
101
|
-
.to update_index(DummiesIndex
|
102
|
+
.to update_index(DummiesIndex).and_delete(41, times: 2).only
|
102
103
|
end
|
103
104
|
.to fail_matching 'to delete documents ["41"] only, but ["42"] was deleted also'
|
104
105
|
end
|
@@ -106,57 +107,57 @@ describe :update_index do
|
|
106
107
|
specify do
|
107
108
|
expect do
|
108
109
|
expect { DummiesIndex::Dummy.bulk body: [{index: {_id: 42, data: {}}}, {delete: {_id: 41}}] }
|
109
|
-
.to update_index(DummiesIndex
|
110
|
+
.to update_index(DummiesIndex).and_reindex(42).only
|
110
111
|
end
|
111
112
|
.to fail_matching 'to update documents ["42"] only, but ["41"] was deleted also'
|
112
113
|
end
|
113
114
|
specify do
|
114
115
|
expect do
|
115
116
|
expect { DummiesIndex::Dummy.bulk body: [{index: {_id: 42, data: {}}}, {index: {_id: 43, data: {}}}, {delete: {_id: 41}}] }
|
116
|
-
.to update_index(DummiesIndex
|
117
|
+
.to update_index(DummiesIndex).and_reindex(42).only
|
117
118
|
end
|
118
119
|
.to fail_matching 'to update documents ["42"] only, but ["43"] was updated and ["41"] was deleted also'
|
119
120
|
end
|
120
121
|
specify do
|
121
122
|
expect do
|
122
123
|
expect { DummiesIndex::Dummy.bulk body: [{index: {_id: 42, data: {}}}, {delete: {_id: 41}}] }
|
123
|
-
.to update_index(DummiesIndex
|
124
|
+
.to update_index(DummiesIndex).and_delete(41).only
|
124
125
|
end
|
125
126
|
.to fail_matching 'to delete documents ["41"] only, but ["42"] was updated also'
|
126
127
|
end
|
127
128
|
specify do
|
128
129
|
expect do
|
129
130
|
expect { DummiesIndex::Dummy.bulk body: [{index: {_id: 42, data: {}}}, {delete: {_id: 41}}, {delete: {_id: 43}}] }
|
130
|
-
.to update_index(DummiesIndex
|
131
|
+
.to update_index(DummiesIndex).and_delete(41).only
|
131
132
|
end
|
132
133
|
.to fail_matching 'to delete documents ["41"] only, but ["42"] was updated and ["43"] was deleted also'
|
133
134
|
end
|
134
135
|
end
|
135
136
|
|
136
137
|
context '#and_reindex' do
|
137
|
-
specify { expect { DummiesIndex::Dummy.bulk body: [{index: {_id: 42}}] }.to update_index(DummiesIndex
|
138
|
+
specify { expect { DummiesIndex::Dummy.bulk body: [{index: {_id: 42}}] }.to update_index(DummiesIndex) }
|
138
139
|
specify do
|
139
140
|
expect { DummiesIndex::Dummy.bulk body: [{index: {_id: 42, data: {}}}] }
|
140
|
-
.to update_index(DummiesIndex
|
141
|
+
.to update_index(DummiesIndex).and_reindex(42)
|
141
142
|
end
|
142
143
|
specify do
|
143
144
|
expect { DummiesIndex::Dummy.bulk body: [{index: {_id: 42, data: {}}}, {index: {_id: 43, data: {}}}] }
|
144
|
-
.to update_index(DummiesIndex
|
145
|
+
.to update_index(DummiesIndex).and_reindex(double(id: 42))
|
145
146
|
end
|
146
147
|
specify do
|
147
148
|
expect { DummiesIndex::Dummy.bulk body: [{index: {_id: 42, data: {}}}, {index: {_id: 43, data: {}}}] }
|
148
|
-
.to update_index(DummiesIndex
|
149
|
+
.to update_index(DummiesIndex).and_reindex(double(id: 42), double(id: 43))
|
149
150
|
end
|
150
151
|
specify do
|
151
152
|
expect { DummiesIndex::Dummy.bulk body: [{index: {_id: 42, data: {}}}, {index: {_id: 43, data: {}}}] }
|
152
|
-
.to update_index(DummiesIndex
|
153
|
+
.to update_index(DummiesIndex).and_reindex([double(id: 42), 43])
|
153
154
|
end
|
154
155
|
|
155
156
|
specify do
|
156
157
|
expect do
|
157
158
|
expect do
|
158
159
|
DummiesIndex::Dummy.bulk body: [{index: {_id: 42, data: {}}}, {index: {_id: 43, data: {}}}]
|
159
|
-
end.to update_index(DummiesIndex
|
160
|
+
end.to update_index(DummiesIndex).and_reindex([44, 43])
|
160
161
|
end.to fail_matching 'Expected document with id `44` to be reindexed, but it was not'
|
161
162
|
end
|
162
163
|
|
@@ -165,7 +166,7 @@ describe :update_index do
|
|
165
166
|
expect do
|
166
167
|
expect do
|
167
168
|
DummiesIndex::Dummy.bulk body: [{index: {_id: 42, data: {}}}, {index: {_id: 43, data: {}}}]
|
168
|
-
end.to update_index(DummiesIndex
|
169
|
+
end.to update_index(DummiesIndex).and_reindex(44, double(id: 47)) end
|
169
170
|
end
|
170
171
|
|
171
172
|
specify { expectation.to fail_matching('Expected document with id `44` to be reindexed, but it was not') }
|
@@ -177,13 +178,13 @@ describe :update_index do
|
|
177
178
|
expect do
|
178
179
|
DummiesIndex::Dummy.bulk body: [{index: {_id: 42, data: {}}}, {index: {_id: 43, data: {}}}]
|
179
180
|
DummiesIndex::Dummy.bulk body: [{index: {_id: 43, data: {}}}, {index: {_id: 44, data: {}}}]
|
180
|
-
end.to update_index(DummiesIndex
|
181
|
+
end.to update_index(DummiesIndex).and_reindex(42, 44, times: 1).and_reindex(43, times: 2) end
|
181
182
|
|
182
183
|
specify do
|
183
184
|
expect do
|
184
185
|
expect do
|
185
186
|
DummiesIndex::Dummy.bulk body: [{index: {_id: 43, data: {a: '1'}}}]
|
186
|
-
end.to update_index(DummiesIndex
|
187
|
+
end.to update_index(DummiesIndex).and_reindex(42, times: 3)
|
187
188
|
end.to fail_matching('Expected document with id `42` to be reindexed, but it was not') end
|
188
189
|
|
189
190
|
context do
|
@@ -192,7 +193,7 @@ describe :update_index do
|
|
192
193
|
expect do
|
193
194
|
DummiesIndex::Dummy.bulk body: [{index: {_id: 42, data: {}}}, {index: {_id: 43, data: {}}}]
|
194
195
|
DummiesIndex::Dummy.bulk body: [{index: {_id: 43, data: {}}}, {index: {_id: 44, data: {}}}]
|
195
|
-
end.to update_index(DummiesIndex
|
196
|
+
end.to update_index(DummiesIndex).and_reindex(42, times: 3).and_reindex(44, 43, times: 4) end
|
196
197
|
end
|
197
198
|
|
198
199
|
specify { expectation.to fail_matching 'Expected document with id `44` to be reindexed' }
|
@@ -206,18 +207,18 @@ describe :update_index do
|
|
206
207
|
specify do
|
207
208
|
expect do
|
208
209
|
DummiesIndex::Dummy.bulk body: [{index: {_id: 42, data: {a: '1'}}}, {index: {_id: 42, data: {'a' => 2}}}]
|
209
|
-
end.to update_index(DummiesIndex
|
210
|
+
end.to update_index(DummiesIndex).and_reindex(42, with: {a: 2}) end
|
210
211
|
|
211
212
|
specify do
|
212
213
|
expect do
|
213
214
|
DummiesIndex::Dummy.bulk body: [{index: {_id: 42, data: {a: '1'}}}, {index: {_id: 42, data: {'b' => 2}}}]
|
214
|
-
end.to update_index(DummiesIndex
|
215
|
+
end.to update_index(DummiesIndex).and_reindex(42, with: {a: '1', b: 2}) end
|
215
216
|
|
216
217
|
specify do
|
217
218
|
expect do
|
218
219
|
expect do
|
219
220
|
DummiesIndex::Dummy.bulk body: [{index: {_id: 43, data: {a: '1'}}}]
|
220
|
-
end.to update_index(DummiesIndex
|
221
|
+
end.to update_index(DummiesIndex).and_reindex(42, with: {a: 1})
|
221
222
|
end.to fail_matching('Expected document with id `42` to be reindexed, but it was not') end
|
222
223
|
|
223
224
|
[
|
@@ -230,7 +231,7 @@ describe :update_index do
|
|
230
231
|
specify do
|
231
232
|
expect do
|
232
233
|
DummiesIndex::Dummy.bulk body: [{index: {_id: 42, data: data}}]
|
233
|
-
end.to update_index(DummiesIndex
|
234
|
+
end.to update_index(DummiesIndex).and_reindex(42, with: with) end
|
234
235
|
end
|
235
236
|
|
236
237
|
[
|
@@ -244,7 +245,7 @@ describe :update_index do
|
|
244
245
|
expect do
|
245
246
|
expect do
|
246
247
|
DummiesIndex::Dummy.bulk body: [{index: {_id: 42, data: data}}]
|
247
|
-
end.to update_index(DummiesIndex
|
248
|
+
end.to update_index(DummiesIndex).and_reindex(42, with: with)
|
248
249
|
end.to fail_matching('Expected document with id `42` to be reindexed') end
|
249
250
|
end
|
250
251
|
|
@@ -253,7 +254,7 @@ describe :update_index do
|
|
253
254
|
expect do
|
254
255
|
expect do
|
255
256
|
DummiesIndex::Dummy.bulk body: [{index: {_id: 43, data: {a: '1'}}}, {index: {_id: 42, data: {'a' => 2}}}]
|
256
|
-
end.to update_index(DummiesIndex
|
257
|
+
end.to update_index(DummiesIndex).and_reindex(43, times: 2, with: {a: 2}) end
|
257
258
|
end
|
258
259
|
|
259
260
|
specify { expectation.to fail_matching 'Expected document with id `43` to be reindexed' }
|
@@ -266,26 +267,26 @@ describe :update_index do
|
|
266
267
|
context '#and_delete' do
|
267
268
|
specify do
|
268
269
|
expect { DummiesIndex::Dummy.bulk body: [{index: {_id: 42, data: {}}}, {delete: {_id: 43}}] }
|
269
|
-
.to update_index(DummiesIndex
|
270
|
+
.to update_index(DummiesIndex).and_reindex(42).and_delete(double(id: 43))
|
270
271
|
end
|
271
272
|
specify do
|
272
273
|
expect { DummiesIndex::Dummy.bulk body: [{delete: {_id: 42}}, {delete: {_id: 43}}] }
|
273
|
-
.to update_index(DummiesIndex
|
274
|
+
.to update_index(DummiesIndex).and_delete(42).and_delete(double(id: 43))
|
274
275
|
end
|
275
276
|
specify do
|
276
277
|
expect { DummiesIndex::Dummy.bulk body: [{delete: {_id: 42}}, {delete: {_id: 43}}] }
|
277
|
-
.to update_index(DummiesIndex
|
278
|
+
.to update_index(DummiesIndex).and_delete(42, double(id: 43))
|
278
279
|
end
|
279
280
|
specify do
|
280
281
|
expect { DummiesIndex::Dummy.bulk body: [{delete: {_id: 42}}, {delete: {_id: 43}}] }
|
281
|
-
.to update_index(DummiesIndex
|
282
|
+
.to update_index(DummiesIndex).and_delete([43, double(id: 42)])
|
282
283
|
end
|
283
284
|
|
284
285
|
context do
|
285
286
|
let(:expectation) do
|
286
287
|
expect do
|
287
288
|
expect { DummiesIndex::Dummy.bulk body: [{index: {_id: 42, data: {}}}, {delete: {_id: 43}}] }
|
288
|
-
.to update_index(DummiesIndex
|
289
|
+
.to update_index(DummiesIndex).and_reindex(43).and_delete(double(id: 42))
|
289
290
|
end
|
290
291
|
end
|
291
292
|
|
@@ -297,7 +298,7 @@ describe :update_index do
|
|
297
298
|
let(:expectation) do
|
298
299
|
expect do
|
299
300
|
expect { DummiesIndex::Dummy.bulk body: [{delete: {_id: 42, data: {}}}, {delete: {_id: 42}}] }
|
300
|
-
.to update_index(DummiesIndex
|
301
|
+
.to update_index(DummiesIndex).and_delete(44, times: 2).and_delete(double(id: 42), times: 3)
|
301
302
|
end
|
302
303
|
end
|
303
304
|
|
data/spec/chewy/runtime_spec.rb
CHANGED
@@ -3,7 +3,7 @@ require 'spec_helper'
|
|
3
3
|
describe Chewy::Runtime do
|
4
4
|
describe '.version' do
|
5
5
|
specify { expect(described_class.version).to be_a(described_class::Version) }
|
6
|
-
specify { expect(described_class.version).to be >= '
|
7
|
-
specify { expect(described_class.version).to be < '
|
6
|
+
specify { expect(described_class.version).to be >= '6.8' }
|
7
|
+
specify { expect(described_class.version).to be < '8.0' }
|
8
8
|
end
|
9
9
|
end
|
@@ -0,0 +1,190 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Chewy::Search::Parameters::Indices do
|
4
|
+
before do
|
5
|
+
stub_index(:first) do
|
6
|
+
define_type :one
|
7
|
+
end
|
8
|
+
|
9
|
+
stub_index(:second) do
|
10
|
+
define_type :three
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
subject { described_class.new(indices: FirstIndex, types: SecondIndex::Three) }
|
15
|
+
|
16
|
+
describe '#initialize' do
|
17
|
+
specify { expect(described_class.new.value).to eq(indices: [], types: []) }
|
18
|
+
specify { expect(described_class.new(nil).value).to eq(indices: [], types: []) }
|
19
|
+
specify { expect(described_class.new(foo: :whatever).value).to eq(indices: [], types: []) }
|
20
|
+
specify { expect(subject.value).to eq(indices: [FirstIndex], types: [SecondIndex::Three]) }
|
21
|
+
end
|
22
|
+
|
23
|
+
describe '#replace!' do
|
24
|
+
specify do
|
25
|
+
expect { subject.replace!(nil) }
|
26
|
+
.to change { subject.value }
|
27
|
+
.from(indices: [FirstIndex], types: [SecondIndex::Three])
|
28
|
+
.to(indices: [], types: [])
|
29
|
+
end
|
30
|
+
|
31
|
+
specify do
|
32
|
+
expect { subject.replace!(indices: SecondIndex, types: FirstIndex::One) }
|
33
|
+
.to change { subject.value }
|
34
|
+
.from(indices: [FirstIndex], types: [SecondIndex::Three])
|
35
|
+
.to(indices: [SecondIndex], types: [FirstIndex::One])
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
describe '#update!' do
|
40
|
+
specify do
|
41
|
+
expect { subject.update!(nil) }
|
42
|
+
.not_to change { subject.value }
|
43
|
+
end
|
44
|
+
|
45
|
+
specify do
|
46
|
+
expect { subject.update!(indices: SecondIndex, types: [FirstIndex::One, SecondIndex::Three]) }
|
47
|
+
.to change { subject.value }
|
48
|
+
.from(indices: [FirstIndex], types: [SecondIndex::Three])
|
49
|
+
.to(indices: [FirstIndex, SecondIndex], types: [SecondIndex::Three, FirstIndex::One])
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
describe '#merge!' do
|
54
|
+
specify do
|
55
|
+
expect { subject.merge!(described_class.new) }
|
56
|
+
.not_to change { subject.value }
|
57
|
+
end
|
58
|
+
|
59
|
+
specify do
|
60
|
+
expect { subject.merge!(described_class.new(indices: SecondIndex, types: [FirstIndex::One, SecondIndex::Three])) }
|
61
|
+
.to change { subject.value }
|
62
|
+
.from(indices: [FirstIndex], types: [SecondIndex::Three])
|
63
|
+
.to(indices: [FirstIndex, SecondIndex], types: [SecondIndex::Three, FirstIndex::One])
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
describe '#render' do
|
68
|
+
specify { expect(described_class.new.render).to eq({}) }
|
69
|
+
specify do
|
70
|
+
expect(described_class.new(
|
71
|
+
indices: FirstIndex
|
72
|
+
).render).to eq(index: %w[first], type: %w[one])
|
73
|
+
end
|
74
|
+
specify do
|
75
|
+
expect(described_class.new(
|
76
|
+
indices: :whatever
|
77
|
+
).render).to eq(index: %w[whatever])
|
78
|
+
end
|
79
|
+
specify do
|
80
|
+
expect(described_class.new(
|
81
|
+
types: FirstIndex::One
|
82
|
+
).render).to eq(index: %w[first], type: %w[one])
|
83
|
+
end
|
84
|
+
specify do
|
85
|
+
expect(described_class.new(
|
86
|
+
types: :whatever
|
87
|
+
).render).to eq({})
|
88
|
+
end
|
89
|
+
specify do
|
90
|
+
expect(described_class.new(
|
91
|
+
indices: FirstIndex, types: SecondIndex::Three
|
92
|
+
).render).to eq(index: %w[first second], type: %w[one three])
|
93
|
+
end
|
94
|
+
specify do
|
95
|
+
expect(described_class.new(
|
96
|
+
indices: FirstIndex, types: :one
|
97
|
+
).render).to eq(index: %w[first], type: %w[one])
|
98
|
+
end
|
99
|
+
specify do
|
100
|
+
expect(described_class.new(
|
101
|
+
indices: FirstIndex, types: :whatever
|
102
|
+
).render).to eq(index: %w[first], type: %w[one])
|
103
|
+
end
|
104
|
+
specify do
|
105
|
+
expect(described_class.new(
|
106
|
+
indices: FirstIndex, types: %i[one whatever]
|
107
|
+
).render).to eq(index: %w[first], type: %w[one])
|
108
|
+
end
|
109
|
+
specify do
|
110
|
+
expect(described_class.new(
|
111
|
+
indices: :whatever, types: SecondIndex::Three
|
112
|
+
).render).to eq(index: %w[second whatever], type: %w[three])
|
113
|
+
end
|
114
|
+
specify do
|
115
|
+
expect(described_class.new(
|
116
|
+
indices: :whatever, types: [SecondIndex::Three, :whatever]
|
117
|
+
).render).to eq(index: %w[second whatever], type: %w[three whatever])
|
118
|
+
end
|
119
|
+
specify do
|
120
|
+
expect(described_class.new(
|
121
|
+
indices: [FirstIndex, :whatever], types: FirstIndex::One
|
122
|
+
).render).to eq(index: %w[first whatever], type: %w[one])
|
123
|
+
end
|
124
|
+
specify do
|
125
|
+
expect(described_class.new(
|
126
|
+
indices: FirstIndex, types: [FirstIndex::One, :whatever]
|
127
|
+
).render).to eq(index: %w[first], type: %w[one])
|
128
|
+
end
|
129
|
+
specify do
|
130
|
+
expect(described_class.new(
|
131
|
+
indices: FirstIndex, types: [SecondIndex::Three, :whatever]
|
132
|
+
).render).to eq(index: %w[first second], type: %w[one three])
|
133
|
+
end
|
134
|
+
specify do
|
135
|
+
expect(described_class.new(
|
136
|
+
indices: [FirstIndex, :whatever], types: [FirstIndex::One, :whatever]
|
137
|
+
).render).to eq(index: %w[first whatever], type: %w[one whatever])
|
138
|
+
end
|
139
|
+
specify do
|
140
|
+
expect(described_class.new(
|
141
|
+
indices: [FirstIndex, :whatever], types: [SecondIndex::Three, FirstIndex::One]
|
142
|
+
).render).to eq(index: %w[first second whatever], type: %w[one three])
|
143
|
+
end
|
144
|
+
end
|
145
|
+
|
146
|
+
describe '#==' do
|
147
|
+
specify { expect(described_class.new).to eq(described_class.new) }
|
148
|
+
specify do
|
149
|
+
expect(described_class.new(indices: SecondIndex, types: [SecondIndex::Three, :whatever]))
|
150
|
+
.to eq(described_class.new(indices: SecondIndex, types: :whatever))
|
151
|
+
end
|
152
|
+
specify do
|
153
|
+
expect(described_class.new(indices: :first, types: %w[one]))
|
154
|
+
.to eq(described_class.new(indices: FirstIndex))
|
155
|
+
end
|
156
|
+
specify do
|
157
|
+
expect(described_class.new(indices: FirstIndex, types: SecondIndex::Three))
|
158
|
+
.not_to eq(described_class.new(indices: FirstIndex))
|
159
|
+
end
|
160
|
+
end
|
161
|
+
|
162
|
+
describe '#indices' do
|
163
|
+
specify do
|
164
|
+
expect(described_class.new(
|
165
|
+
indices: [FirstIndex, :whatever],
|
166
|
+
types: [SecondIndex::Three, :whatever]
|
167
|
+
).indices).to contain_exactly(FirstIndex, SecondIndex)
|
168
|
+
end
|
169
|
+
end
|
170
|
+
|
171
|
+
describe '#types' do
|
172
|
+
specify do
|
173
|
+
expect(described_class.new(
|
174
|
+
indices: [FirstIndex, :whatever],
|
175
|
+
types: [SecondIndex::Three, :whatever]
|
176
|
+
).types).to contain_exactly(
|
177
|
+
FirstIndex::One, SecondIndex::Three
|
178
|
+
)
|
179
|
+
end
|
180
|
+
|
181
|
+
specify do
|
182
|
+
expect(described_class.new(
|
183
|
+
indices: [FirstIndex, :whatever],
|
184
|
+
types: [FirstIndex::One, SecondIndex::Three, :whatever]
|
185
|
+
).types).to contain_exactly(
|
186
|
+
FirstIndex::One, SecondIndex::Three
|
187
|
+
)
|
188
|
+
end
|
189
|
+
end
|
190
|
+
end
|