chewy 0.10.1 → 7.3.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (243) hide show
  1. checksums.yaml +5 -5
  2. data/.github/CODEOWNERS +1 -0
  3. data/.github/ISSUE_TEMPLATE/bug_report.md +39 -0
  4. data/.github/ISSUE_TEMPLATE/feature_request.md +20 -0
  5. data/.github/PULL_REQUEST_TEMPLATE.md +16 -0
  6. data/.github/workflows/ruby.yml +74 -0
  7. data/.rubocop.yml +28 -23
  8. data/.rubocop_todo.yml +110 -22
  9. data/CHANGELOG.md +480 -298
  10. data/CODE_OF_CONDUCT.md +14 -0
  11. data/CONTRIBUTING.md +63 -0
  12. data/Gemfile +3 -5
  13. data/Guardfile +3 -1
  14. data/LICENSE.txt +1 -1
  15. data/README.md +571 -333
  16. data/chewy.gemspec +12 -15
  17. data/gemfiles/rails.5.2.activerecord.gemfile +11 -0
  18. data/gemfiles/rails.6.0.activerecord.gemfile +11 -0
  19. data/gemfiles/rails.6.1.activerecord.gemfile +13 -0
  20. data/gemfiles/rails.7.0.activerecord.gemfile +13 -0
  21. data/lib/chewy/config.rb +48 -77
  22. data/lib/chewy/errors.rb +4 -10
  23. data/lib/chewy/fields/base.rb +88 -16
  24. data/lib/chewy/fields/root.rb +15 -21
  25. data/lib/chewy/index/actions.rb +67 -38
  26. data/lib/chewy/{type → index}/adapter/active_record.rb +18 -4
  27. data/lib/chewy/{type → index}/adapter/base.rb +11 -12
  28. data/lib/chewy/{type → index}/adapter/object.rb +28 -32
  29. data/lib/chewy/{type → index}/adapter/orm.rb +26 -24
  30. data/lib/chewy/index/aliases.rb +14 -5
  31. data/lib/chewy/index/crutch.rb +40 -0
  32. data/lib/chewy/index/import/bulk_builder.rb +311 -0
  33. data/lib/chewy/{type → index}/import/bulk_request.rb +10 -9
  34. data/lib/chewy/{type → index}/import/journal_builder.rb +11 -12
  35. data/lib/chewy/{type → index}/import/routine.rb +19 -18
  36. data/lib/chewy/{type → index}/import.rb +82 -36
  37. data/lib/chewy/{type → index}/mapping.rb +63 -62
  38. data/lib/chewy/index/observe/active_record_methods.rb +87 -0
  39. data/lib/chewy/index/observe/callback.rb +34 -0
  40. data/lib/chewy/index/observe.rb +17 -0
  41. data/lib/chewy/index/settings.rb +2 -0
  42. data/lib/chewy/index/specification.rb +13 -10
  43. data/lib/chewy/{type → index}/syncer.rb +62 -63
  44. data/lib/chewy/{type → index}/witchcraft.rb +15 -9
  45. data/lib/chewy/{type → index}/wrapper.rb +16 -6
  46. data/lib/chewy/index.rb +68 -93
  47. data/lib/chewy/journal.rb +25 -14
  48. data/lib/chewy/minitest/helpers.rb +91 -18
  49. data/lib/chewy/minitest/search_index_receiver.rb +29 -33
  50. data/lib/chewy/multi_search.rb +62 -0
  51. data/lib/chewy/railtie.rb +8 -24
  52. data/lib/chewy/rake_helper.rb +141 -112
  53. data/lib/chewy/rspec/build_query.rb +12 -0
  54. data/lib/chewy/rspec/helpers.rb +55 -0
  55. data/lib/chewy/rspec/update_index.rb +58 -49
  56. data/lib/chewy/rspec.rb +2 -0
  57. data/lib/chewy/runtime.rb +1 -1
  58. data/lib/chewy/search/loader.rb +19 -41
  59. data/lib/chewy/search/parameters/allow_partial_search_results.rb +27 -0
  60. data/lib/chewy/search/parameters/collapse.rb +16 -0
  61. data/lib/chewy/search/parameters/concerns/query_storage.rb +6 -5
  62. data/lib/chewy/search/parameters/ignore_unavailable.rb +27 -0
  63. data/lib/chewy/search/parameters/indices.rb +78 -0
  64. data/lib/chewy/search/parameters/none.rb +1 -3
  65. data/lib/chewy/search/parameters/order.rb +6 -19
  66. data/lib/chewy/search/parameters/source.rb +5 -1
  67. data/lib/chewy/search/parameters/track_total_hits.rb +16 -0
  68. data/lib/chewy/search/parameters.rb +28 -8
  69. data/lib/chewy/search/query_proxy.rb +9 -2
  70. data/lib/chewy/search/request.rb +207 -157
  71. data/lib/chewy/search/response.rb +5 -5
  72. data/lib/chewy/search/scoping.rb +7 -8
  73. data/lib/chewy/search/scrolling.rb +14 -13
  74. data/lib/chewy/search.rb +7 -26
  75. data/lib/chewy/stash.rb +27 -29
  76. data/lib/chewy/strategy/active_job.rb +2 -2
  77. data/lib/chewy/strategy/atomic.rb +1 -1
  78. data/lib/chewy/strategy/atomic_no_refresh.rb +18 -0
  79. data/lib/chewy/strategy/base.rb +10 -0
  80. data/lib/chewy/strategy/delayed_sidekiq/scheduler.rb +148 -0
  81. data/lib/chewy/strategy/delayed_sidekiq/worker.rb +52 -0
  82. data/lib/chewy/strategy/delayed_sidekiq.rb +17 -0
  83. data/lib/chewy/strategy/lazy_sidekiq.rb +64 -0
  84. data/lib/chewy/strategy/sidekiq.rb +3 -2
  85. data/lib/chewy/strategy.rb +6 -19
  86. data/lib/chewy/version.rb +1 -1
  87. data/lib/chewy.rb +37 -80
  88. data/lib/generators/chewy/install_generator.rb +1 -1
  89. data/lib/tasks/chewy.rake +26 -32
  90. data/migration_guide.md +56 -0
  91. data/spec/chewy/config_spec.rb +27 -57
  92. data/spec/chewy/fields/base_spec.rb +457 -174
  93. data/spec/chewy/fields/root_spec.rb +24 -32
  94. data/spec/chewy/fields/time_fields_spec.rb +5 -5
  95. data/spec/chewy/index/actions_spec.rb +425 -60
  96. data/spec/chewy/{type → index}/adapter/active_record_spec.rb +110 -44
  97. data/spec/chewy/{type → index}/adapter/object_spec.rb +21 -6
  98. data/spec/chewy/index/aliases_spec.rb +3 -3
  99. data/spec/chewy/index/import/bulk_builder_spec.rb +494 -0
  100. data/spec/chewy/{type → index}/import/bulk_request_spec.rb +5 -12
  101. data/spec/chewy/{type → index}/import/journal_builder_spec.rb +22 -30
  102. data/spec/chewy/{type → index}/import/routine_spec.rb +19 -19
  103. data/spec/chewy/{type → index}/import_spec.rb +154 -95
  104. data/spec/chewy/index/mapping_spec.rb +135 -0
  105. data/spec/chewy/index/observe/active_record_methods_spec.rb +68 -0
  106. data/spec/chewy/index/observe/callback_spec.rb +139 -0
  107. data/spec/chewy/index/observe_spec.rb +143 -0
  108. data/spec/chewy/index/settings_spec.rb +3 -1
  109. data/spec/chewy/index/specification_spec.rb +32 -33
  110. data/spec/chewy/{type → index}/syncer_spec.rb +14 -19
  111. data/spec/chewy/{type → index}/witchcraft_spec.rb +34 -21
  112. data/spec/chewy/index/wrapper_spec.rb +100 -0
  113. data/spec/chewy/index_spec.rb +99 -114
  114. data/spec/chewy/journal_spec.rb +56 -101
  115. data/spec/chewy/minitest/helpers_spec.rb +122 -14
  116. data/spec/chewy/minitest/search_index_receiver_spec.rb +24 -26
  117. data/spec/chewy/multi_search_spec.rb +84 -0
  118. data/spec/chewy/rake_helper_spec.rb +325 -101
  119. data/spec/chewy/rspec/build_query_spec.rb +34 -0
  120. data/spec/chewy/rspec/helpers_spec.rb +61 -0
  121. data/spec/chewy/rspec/update_index_spec.rb +106 -102
  122. data/spec/chewy/runtime_spec.rb +2 -2
  123. data/spec/chewy/search/loader_spec.rb +19 -53
  124. data/spec/chewy/search/pagination/kaminari_examples.rb +3 -5
  125. data/spec/chewy/search/pagination/kaminari_spec.rb +1 -1
  126. data/spec/chewy/search/parameters/collapse_spec.rb +5 -0
  127. data/spec/chewy/search/parameters/ignore_unavailable_spec.rb +67 -0
  128. data/spec/chewy/search/parameters/indices_spec.rb +99 -0
  129. data/spec/chewy/search/parameters/none_spec.rb +1 -1
  130. data/spec/chewy/search/parameters/order_spec.rb +18 -11
  131. data/spec/chewy/search/parameters/query_storage_examples.rb +67 -21
  132. data/spec/chewy/search/parameters/search_after_spec.rb +4 -1
  133. data/spec/chewy/search/parameters/source_spec.rb +8 -2
  134. data/spec/chewy/search/parameters/track_total_hits_spec.rb +5 -0
  135. data/spec/chewy/search/parameters_spec.rb +39 -8
  136. data/spec/chewy/search/query_proxy_spec.rb +68 -17
  137. data/spec/chewy/search/request_spec.rb +360 -149
  138. data/spec/chewy/search/response_spec.rb +35 -25
  139. data/spec/chewy/search/scrolling_spec.rb +28 -26
  140. data/spec/chewy/search_spec.rb +73 -53
  141. data/spec/chewy/stash_spec.rb +16 -26
  142. data/spec/chewy/strategy/active_job_spec.rb +23 -10
  143. data/spec/chewy/strategy/atomic_no_refresh_spec.rb +60 -0
  144. data/spec/chewy/strategy/atomic_spec.rb +9 -10
  145. data/spec/chewy/strategy/delayed_sidekiq_spec.rb +190 -0
  146. data/spec/chewy/strategy/lazy_sidekiq_spec.rb +214 -0
  147. data/spec/chewy/strategy/sidekiq_spec.rb +14 -10
  148. data/spec/chewy/strategy_spec.rb +19 -15
  149. data/spec/chewy_spec.rb +17 -110
  150. data/spec/spec_helper.rb +7 -22
  151. data/spec/support/active_record.rb +43 -5
  152. metadata +123 -198
  153. data/.travis.yml +0 -53
  154. data/Appraisals +0 -79
  155. data/LEGACY_DSL.md +0 -497
  156. data/gemfiles/rails.4.0.activerecord.gemfile +0 -14
  157. data/gemfiles/rails.4.1.activerecord.gemfile +0 -14
  158. data/gemfiles/rails.4.2.activerecord.gemfile +0 -15
  159. data/gemfiles/rails.4.2.mongoid.5.1.gemfile +0 -15
  160. data/gemfiles/rails.5.0.activerecord.gemfile +0 -15
  161. data/gemfiles/rails.5.0.mongoid.6.0.gemfile +0 -15
  162. data/gemfiles/rails.5.1.activerecord.gemfile +0 -15
  163. data/gemfiles/rails.5.1.mongoid.6.1.gemfile +0 -15
  164. data/gemfiles/sequel.4.45.gemfile +0 -11
  165. data/lib/chewy/backports/deep_dup.rb +0 -46
  166. data/lib/chewy/backports/duplicable.rb +0 -91
  167. data/lib/chewy/query/compose.rb +0 -68
  168. data/lib/chewy/query/criteria.rb +0 -191
  169. data/lib/chewy/query/filters.rb +0 -227
  170. data/lib/chewy/query/loading.rb +0 -111
  171. data/lib/chewy/query/nodes/and.rb +0 -25
  172. data/lib/chewy/query/nodes/base.rb +0 -17
  173. data/lib/chewy/query/nodes/bool.rb +0 -34
  174. data/lib/chewy/query/nodes/equal.rb +0 -34
  175. data/lib/chewy/query/nodes/exists.rb +0 -20
  176. data/lib/chewy/query/nodes/expr.rb +0 -28
  177. data/lib/chewy/query/nodes/field.rb +0 -110
  178. data/lib/chewy/query/nodes/has_child.rb +0 -15
  179. data/lib/chewy/query/nodes/has_parent.rb +0 -15
  180. data/lib/chewy/query/nodes/has_relation.rb +0 -59
  181. data/lib/chewy/query/nodes/match_all.rb +0 -11
  182. data/lib/chewy/query/nodes/missing.rb +0 -20
  183. data/lib/chewy/query/nodes/not.rb +0 -25
  184. data/lib/chewy/query/nodes/or.rb +0 -25
  185. data/lib/chewy/query/nodes/prefix.rb +0 -19
  186. data/lib/chewy/query/nodes/query.rb +0 -20
  187. data/lib/chewy/query/nodes/range.rb +0 -63
  188. data/lib/chewy/query/nodes/raw.rb +0 -15
  189. data/lib/chewy/query/nodes/regexp.rb +0 -35
  190. data/lib/chewy/query/nodes/script.rb +0 -20
  191. data/lib/chewy/query/pagination.rb +0 -25
  192. data/lib/chewy/query.rb +0 -1098
  193. data/lib/chewy/search/pagination/will_paginate.rb +0 -43
  194. data/lib/chewy/search/parameters/types.rb +0 -20
  195. data/lib/chewy/strategy/resque.rb +0 -27
  196. data/lib/chewy/strategy/shoryuken.rb +0 -40
  197. data/lib/chewy/type/actions.rb +0 -43
  198. data/lib/chewy/type/adapter/mongoid.rb +0 -69
  199. data/lib/chewy/type/adapter/sequel.rb +0 -95
  200. data/lib/chewy/type/crutch.rb +0 -32
  201. data/lib/chewy/type/import/bulk_builder.rb +0 -122
  202. data/lib/chewy/type/observe.rb +0 -78
  203. data/lib/chewy/type.rb +0 -117
  204. data/lib/sequel/plugins/chewy_observe.rb +0 -78
  205. data/spec/chewy/query/criteria_spec.rb +0 -700
  206. data/spec/chewy/query/filters_spec.rb +0 -201
  207. data/spec/chewy/query/loading_spec.rb +0 -124
  208. data/spec/chewy/query/nodes/and_spec.rb +0 -12
  209. data/spec/chewy/query/nodes/bool_spec.rb +0 -14
  210. data/spec/chewy/query/nodes/equal_spec.rb +0 -32
  211. data/spec/chewy/query/nodes/exists_spec.rb +0 -18
  212. data/spec/chewy/query/nodes/has_child_spec.rb +0 -59
  213. data/spec/chewy/query/nodes/has_parent_spec.rb +0 -59
  214. data/spec/chewy/query/nodes/match_all_spec.rb +0 -11
  215. data/spec/chewy/query/nodes/missing_spec.rb +0 -16
  216. data/spec/chewy/query/nodes/not_spec.rb +0 -13
  217. data/spec/chewy/query/nodes/or_spec.rb +0 -12
  218. data/spec/chewy/query/nodes/prefix_spec.rb +0 -16
  219. data/spec/chewy/query/nodes/query_spec.rb +0 -12
  220. data/spec/chewy/query/nodes/range_spec.rb +0 -32
  221. data/spec/chewy/query/nodes/raw_spec.rb +0 -11
  222. data/spec/chewy/query/nodes/regexp_spec.rb +0 -43
  223. data/spec/chewy/query/nodes/script_spec.rb +0 -15
  224. data/spec/chewy/query/pagination/kaminari_spec.rb +0 -5
  225. data/spec/chewy/query/pagination/will_paginate_spec.rb +0 -5
  226. data/spec/chewy/query/pagination_spec.rb +0 -39
  227. data/spec/chewy/query_spec.rb +0 -636
  228. data/spec/chewy/search/pagination/will_paginate_examples.rb +0 -63
  229. data/spec/chewy/search/pagination/will_paginate_spec.rb +0 -23
  230. data/spec/chewy/search/parameters/indices_boost_spec.rb +0 -83
  231. data/spec/chewy/search/parameters/types_spec.rb +0 -5
  232. data/spec/chewy/strategy/resque_spec.rb +0 -46
  233. data/spec/chewy/strategy/shoryuken_spec.rb +0 -64
  234. data/spec/chewy/type/actions_spec.rb +0 -50
  235. data/spec/chewy/type/adapter/mongoid_spec.rb +0 -372
  236. data/spec/chewy/type/adapter/sequel_spec.rb +0 -472
  237. data/spec/chewy/type/import/bulk_builder_spec.rb +0 -279
  238. data/spec/chewy/type/mapping_spec.rb +0 -142
  239. data/spec/chewy/type/observe_spec.rb +0 -137
  240. data/spec/chewy/type/wrapper_spec.rb +0 -98
  241. data/spec/chewy/type_spec.rb +0 -55
  242. data/spec/support/mongoid.rb +0 -93
  243. data/spec/support/sequel.rb +0 -80
@@ -0,0 +1,61 @@
1
+ require 'spec_helper'
2
+
3
+ describe :rspec_helper do
4
+ include ::Chewy::Rspec::Helpers
5
+
6
+ before do
7
+ stub_model(:city)
8
+ stub_index(:cities) { index_scope City }
9
+ CitiesIndex.create
10
+ end
11
+
12
+ let(:hits) do
13
+ [
14
+ {
15
+ '_index' => 'cities',
16
+ '_type' => '_doc',
17
+ '_id' => '1',
18
+ '_score' => 3.14,
19
+ '_source' => source
20
+ }
21
+ ]
22
+ end
23
+
24
+ let(:source) { {'name' => 'some_name'} }
25
+ let(:sources) { [source] }
26
+
27
+ context :mock_elasticsearch_response do
28
+ let(:raw_response) do
29
+ {
30
+ 'took' => 4,
31
+ 'timed_out' => false,
32
+ '_shards' => {
33
+ 'total' => 1,
34
+ 'successful' => 1,
35
+ 'skipped' => 0,
36
+ 'failed' => 0
37
+ },
38
+ 'hits' => {
39
+ 'total' => {
40
+ 'value' => 1,
41
+ 'relation' => 'eq'
42
+ },
43
+ 'max_score' => 1.0,
44
+ 'hits' => hits
45
+ }
46
+ }
47
+ end
48
+
49
+ specify do
50
+ mock_elasticsearch_response(CitiesIndex, raw_response)
51
+ expect(CitiesIndex.query({}).hits).to eq(hits)
52
+ end
53
+ end
54
+
55
+ context :mock_elasticsearch_response_sources do
56
+ specify do
57
+ mock_elasticsearch_response_sources(CitiesIndex, sources)
58
+ expect(CitiesIndex.query({}).hits).to eq(hits)
59
+ end
60
+ end
61
+ end
@@ -3,8 +3,8 @@ require 'spec_helper'
3
3
  describe :update_index do
4
4
  before do
5
5
  stub_index(:dummies) do
6
- define_type :dummy
7
- define_type :dummy2
6
+ end
7
+ stub_index(:dummies2) do
8
8
  end
9
9
  end
10
10
 
@@ -13,27 +13,26 @@ describe :update_index do
13
13
  DummiesIndex.create!
14
14
  end
15
15
 
16
- specify { expect {}.not_to update_index(DummiesIndex::Dummy) }
17
- specify { expect { DummiesIndex::Dummy.bulk body: [] }.not_to update_index(DummiesIndex::Dummy) }
16
+ specify { expect {}.not_to update_index(DummiesIndex) }
17
+ specify { expect { DummiesIndex.bulk body: [] }.not_to update_index(DummiesIndex) }
18
18
 
19
19
  specify do
20
- expect { expect { DummiesIndex::Dummy.bulk body: [{index: {_id: 42}}] }.not_to update_index(DummiesIndex::Dummy) }
20
+ expect { expect { DummiesIndex.bulk body: [{index: {_id: 42}}] }.not_to update_index(DummiesIndex) }
21
21
  .to fail_with(/Expected index .* not to be updated, but it was with/)
22
22
  end
23
23
 
24
24
  specify do
25
25
  expect do
26
- DummiesIndex::Dummy.bulk body: [{index: {_id: 42, data: {}}}, {index: {_id: 41, data: {}}}]
27
- DummiesIndex::Dummy2.bulk body: [{index: {_id: 43, data: {}}}]
28
- end.to update_index(DummiesIndex::Dummy).and_reindex(41, 42).only
26
+ DummiesIndex.bulk body: [{index: {_id: 42, data: {}}}, {index: {_id: 41, data: {}}}]
27
+ end.to update_index(DummiesIndex).and_reindex(41, 42).only
29
28
  end
30
29
 
31
30
  context do
32
31
  let(:expectation) do
33
32
  expect do
34
33
  expect do
35
- DummiesIndex::Dummy.bulk body: [{index: {_id: 42}}, {index: {_id: 41}}, {index: {_id: 42}}]
36
- end.not_to update_index(DummiesIndex::Dummy)
34
+ DummiesIndex.bulk body: [{index: {_id: 42}}, {index: {_id: 41}}, {index: {_id: 42}}]
35
+ end.not_to update_index(DummiesIndex)
37
36
  end
38
37
  end
39
38
 
@@ -44,119 +43,114 @@ describe :update_index do
44
43
  context 'compound matchers' do
45
44
  specify do
46
45
  expect do
47
- DummiesIndex::Dummy.bulk body: [{index: {_id: 42, data: {}}}, {index: {_id: 41, data: {}}}]
48
- DummiesIndex::Dummy2.bulk body: [{index: {_id: 43, data: {}}}]
49
- end.to update_index(DummiesIndex::Dummy).and_reindex(41, 42).only
50
- .and update_index(DummiesIndex::Dummy2).and_reindex(43).only
46
+ DummiesIndex.bulk body: [{index: {_id: 42, data: {}}}, {index: {_id: 41, data: {}}}]
47
+ Dummies2Index.bulk body: [{index: {_id: 43, data: {}}}]
48
+ end.to update_index(DummiesIndex).and_reindex(41, 42).only
49
+ .and update_index(Dummies2Index).and_reindex(43).only
51
50
  end
52
51
 
53
52
  context do
54
53
  let(:expectation) do
55
54
  expect do
56
55
  expect do
57
- DummiesIndex::Dummy2.bulk body: [{index: {_id: 43, data: {}}}]
58
- end.to update_index(DummiesIndex::Dummy).and_reindex(41, 42).only
59
- .and update_index(DummiesIndex::Dummy2).and_reindex(43).only
56
+ Dummies2Index.bulk body: [{index: {_id: 43, data: {}}}]
57
+ end.to update_index(DummiesIndex).and_reindex(41, 42).only
58
+ .and update_index(Dummies2Index).and_reindex(43).only
60
59
  end
61
60
  end
62
61
 
63
- specify { expectation.to fail_matching 'Expected index `DummiesIndex::Dummy` to be updated' }
62
+ specify { expectation.to fail_matching 'Expected index `DummiesIndex` to be updated' }
64
63
  end
65
64
  end
66
65
 
67
66
  context '#only' do
68
67
  specify do
69
- expect { DummiesIndex::Dummy.bulk body: [{index: {_id: 42, data: {}}}, {index: {_id: 41, data: {}}}] }
70
- .to update_index(DummiesIndex::Dummy).and_reindex(41, 42).only
68
+ expect { DummiesIndex.bulk body: [{index: {_id: 42, data: {}}}, {index: {_id: 41, data: {}}}] }
69
+ .to update_index(DummiesIndex).and_reindex(41, 42).only
71
70
  end
72
71
  specify do
73
72
  expect do
74
- expect { DummiesIndex::Dummy.bulk body: [{index: {_id: 42, data: {}}}, {index: {_id: 41, data: {}}}] }
75
- .to update_index(DummiesIndex::Dummy).and_reindex(41).only
76
- end
77
- .to fail_matching 'to update documents ["41"] only, but ["42"] was updated also'
73
+ expect { DummiesIndex.bulk body: [{index: {_id: 42, data: {}}}, {index: {_id: 41, data: {}}}] }
74
+ .to update_index(DummiesIndex).and_reindex(41).only
75
+ end.to fail_matching 'to update documents ["41"] only, but ["42"] was updated also'
78
76
  end
79
77
  specify do
80
78
  expect do
81
- expect { DummiesIndex::Dummy.bulk body: [{index: {_id: 42, data: {}}}, {index: {_id: 41, data: {}}}] }
82
- .to update_index(DummiesIndex::Dummy).and_reindex(41, times: 2).only
83
- end
84
- .to fail_matching 'to update documents ["41"] only, but ["42"] was updated also'
79
+ expect { DummiesIndex.bulk body: [{index: {_id: 42, data: {}}}, {index: {_id: 41, data: {}}}] }
80
+ .to update_index(DummiesIndex).and_reindex(41, times: 2).only
81
+ end.to fail_matching 'to update documents ["41"] only, but ["42"] was updated also'
85
82
  end
86
83
 
87
84
  specify do
88
- expect { DummiesIndex::Dummy.bulk body: [{delete: {_id: 42}}, {delete: {_id: 41}}] }
89
- .to update_index(DummiesIndex::Dummy).and_delete(41, 42).only
85
+ expect { DummiesIndex.bulk body: [{delete: {_id: 42}}, {delete: {_id: 41}}] }
86
+ .to update_index(DummiesIndex).and_delete(41, 42).only
90
87
  end
91
88
  specify do
92
89
  expect do
93
- expect { DummiesIndex::Dummy.bulk body: [{delete: {_id: 42}}, {delete: {_id: 41}}] }
94
- .to update_index(DummiesIndex::Dummy).and_delete(41).only
95
- end
96
- .to fail_matching 'to delete documents ["41"] only, but ["42"] was deleted also'
90
+ expect { DummiesIndex.bulk body: [{delete: {_id: 42}}, {delete: {_id: 41}}] }
91
+ .to update_index(DummiesIndex).and_delete(41).only
92
+ end.to fail_matching 'to delete documents ["41"] only, but ["42"] was deleted also'
97
93
  end
98
94
  specify do
99
95
  expect do
100
- expect { DummiesIndex::Dummy.bulk body: [{delete: {_id: 42}}, {delete: {_id: 41}}] }
101
- .to update_index(DummiesIndex::Dummy).and_delete(41, times: 2).only
102
- end
103
- .to fail_matching 'to delete documents ["41"] only, but ["42"] was deleted also'
96
+ expect { DummiesIndex.bulk body: [{delete: {_id: 42}}, {delete: {_id: 41}}] }
97
+ .to update_index(DummiesIndex).and_delete(41, times: 2).only
98
+ end.to fail_matching 'to delete documents ["41"] only, but ["42"] was deleted also'
104
99
  end
105
100
 
106
101
  specify do
107
102
  expect do
108
- expect { DummiesIndex::Dummy.bulk body: [{index: {_id: 42, data: {}}}, {delete: {_id: 41}}] }
109
- .to update_index(DummiesIndex::Dummy).and_reindex(42).only
110
- end
111
- .to fail_matching 'to update documents ["42"] only, but ["41"] was deleted also'
103
+ expect { DummiesIndex.bulk body: [{index: {_id: 42, data: {}}}, {delete: {_id: 41}}] }
104
+ .to update_index(DummiesIndex).and_reindex(42).only
105
+ end.to fail_matching 'to update documents ["42"] only, but ["41"] was deleted also'
112
106
  end
113
107
  specify do
114
108
  expect do
115
- expect { DummiesIndex::Dummy.bulk body: [{index: {_id: 42, data: {}}}, {index: {_id: 43, data: {}}}, {delete: {_id: 41}}] }
116
- .to update_index(DummiesIndex::Dummy).and_reindex(42).only
117
- end
118
- .to fail_matching 'to update documents ["42"] only, but ["43"] was updated and ["41"] was deleted also'
109
+ expect do
110
+ DummiesIndex.bulk body: [{index: {_id: 42, data: {}}}, {index: {_id: 43, data: {}}},
111
+ {delete: {_id: 41}}]
112
+ end.to update_index(DummiesIndex).and_reindex(42).only
113
+ end.to fail_matching 'to update documents ["42"] only, but ["43"] was updated and ["41"] was deleted also'
119
114
  end
120
115
  specify do
121
116
  expect do
122
- expect { DummiesIndex::Dummy.bulk body: [{index: {_id: 42, data: {}}}, {delete: {_id: 41}}] }
123
- .to update_index(DummiesIndex::Dummy).and_delete(41).only
124
- end
125
- .to fail_matching 'to delete documents ["41"] only, but ["42"] was updated also'
117
+ expect { DummiesIndex.bulk body: [{index: {_id: 42, data: {}}}, {delete: {_id: 41}}] }
118
+ .to update_index(DummiesIndex).and_delete(41).only
119
+ end.to fail_matching 'to delete documents ["41"] only, but ["42"] was updated also'
126
120
  end
127
121
  specify do
128
122
  expect do
129
- expect { DummiesIndex::Dummy.bulk body: [{index: {_id: 42, data: {}}}, {delete: {_id: 41}}, {delete: {_id: 43}}] }
130
- .to update_index(DummiesIndex::Dummy).and_delete(41).only
131
- end
132
- .to fail_matching 'to delete documents ["41"] only, but ["42"] was updated and ["43"] was deleted also'
123
+ expect do
124
+ DummiesIndex.bulk body: [{index: {_id: 42, data: {}}}, {delete: {_id: 41}}, {delete: {_id: 43}}]
125
+ end.to update_index(DummiesIndex).and_delete(41).only
126
+ end.to fail_matching 'to delete documents ["41"] only, but ["42"] was updated and ["43"] was deleted also'
133
127
  end
134
128
  end
135
129
 
136
130
  context '#and_reindex' do
137
- specify { expect { DummiesIndex::Dummy.bulk body: [{index: {_id: 42}}] }.to update_index(DummiesIndex::Dummy) }
131
+ specify { expect { DummiesIndex.bulk body: [{index: {_id: 42}}] }.to update_index(DummiesIndex) }
138
132
  specify do
139
- expect { DummiesIndex::Dummy.bulk body: [{index: {_id: 42, data: {}}}] }
140
- .to update_index(DummiesIndex::Dummy).and_reindex(42)
133
+ expect { DummiesIndex.bulk body: [{index: {_id: 42, data: {}}}] }
134
+ .to update_index(DummiesIndex).and_reindex(42)
141
135
  end
142
136
  specify do
143
- expect { DummiesIndex::Dummy.bulk body: [{index: {_id: 42, data: {}}}, {index: {_id: 43, data: {}}}] }
144
- .to update_index(DummiesIndex::Dummy).and_reindex(double(id: 42))
137
+ expect { DummiesIndex.bulk body: [{index: {_id: 42, data: {}}}, {index: {_id: 43, data: {}}}] }
138
+ .to update_index(DummiesIndex).and_reindex(double(id: 42))
145
139
  end
146
140
  specify do
147
- expect { DummiesIndex::Dummy.bulk body: [{index: {_id: 42, data: {}}}, {index: {_id: 43, data: {}}}] }
148
- .to update_index(DummiesIndex::Dummy).and_reindex(double(id: 42), double(id: 43))
141
+ expect { DummiesIndex.bulk body: [{index: {_id: 42, data: {}}}, {index: {_id: 43, data: {}}}] }
142
+ .to update_index(DummiesIndex).and_reindex(double(id: 42), double(id: 43))
149
143
  end
150
144
  specify do
151
- expect { DummiesIndex::Dummy.bulk body: [{index: {_id: 42, data: {}}}, {index: {_id: 43, data: {}}}] }
152
- .to update_index(DummiesIndex::Dummy).and_reindex([double(id: 42), 43])
145
+ expect { DummiesIndex.bulk body: [{index: {_id: 42, data: {}}}, {index: {_id: 43, data: {}}}] }
146
+ .to update_index(DummiesIndex).and_reindex([double(id: 42), 43])
153
147
  end
154
148
 
155
149
  specify do
156
150
  expect do
157
151
  expect do
158
- DummiesIndex::Dummy.bulk body: [{index: {_id: 42, data: {}}}, {index: {_id: 43, data: {}}}]
159
- end.to update_index(DummiesIndex::Dummy).and_reindex([44, 43])
152
+ DummiesIndex.bulk body: [{index: {_id: 42, data: {}}}, {index: {_id: 43, data: {}}}]
153
+ end.to update_index(DummiesIndex).and_reindex([44, 43])
160
154
  end.to fail_matching 'Expected document with id `44` to be reindexed, but it was not'
161
155
  end
162
156
 
@@ -164,8 +158,9 @@ describe :update_index do
164
158
  let(:expectation) do
165
159
  expect do
166
160
  expect do
167
- DummiesIndex::Dummy.bulk body: [{index: {_id: 42, data: {}}}, {index: {_id: 43, data: {}}}]
168
- end.to update_index(DummiesIndex::Dummy).and_reindex(44, double(id: 47)) end
161
+ DummiesIndex.bulk body: [{index: {_id: 42, data: {}}}, {index: {_id: 43, data: {}}}]
162
+ end.to update_index(DummiesIndex).and_reindex(44, double(id: 47))
163
+ end
169
164
  end
170
165
 
171
166
  specify { expectation.to fail_matching('Expected document with id `44` to be reindexed, but it was not') }
@@ -175,24 +170,27 @@ describe :update_index do
175
170
  context ':times' do
176
171
  specify do
177
172
  expect do
178
- DummiesIndex::Dummy.bulk body: [{index: {_id: 42, data: {}}}, {index: {_id: 43, data: {}}}]
179
- DummiesIndex::Dummy.bulk body: [{index: {_id: 43, data: {}}}, {index: {_id: 44, data: {}}}]
180
- end.to update_index(DummiesIndex::Dummy).and_reindex(42, 44, times: 1).and_reindex(43, times: 2) end
173
+ DummiesIndex.bulk body: [{index: {_id: 42, data: {}}}, {index: {_id: 43, data: {}}}]
174
+ DummiesIndex.bulk body: [{index: {_id: 43, data: {}}}, {index: {_id: 44, data: {}}}]
175
+ end.to update_index(DummiesIndex).and_reindex(42, 44, times: 1).and_reindex(43, times: 2)
176
+ end
181
177
 
182
178
  specify do
183
179
  expect do
184
180
  expect do
185
- DummiesIndex::Dummy.bulk body: [{index: {_id: 43, data: {a: '1'}}}]
186
- end.to update_index(DummiesIndex::Dummy).and_reindex(42, times: 3)
187
- end.to fail_matching('Expected document with id `42` to be reindexed, but it was not') end
181
+ DummiesIndex.bulk body: [{index: {_id: 43, data: {a: '1'}}}]
182
+ end.to update_index(DummiesIndex).and_reindex(42, times: 3)
183
+ end.to fail_matching('Expected document with id `42` to be reindexed, but it was not')
184
+ end
188
185
 
189
186
  context do
190
187
  let(:expectation) do
191
188
  expect do
192
189
  expect do
193
- DummiesIndex::Dummy.bulk body: [{index: {_id: 42, data: {}}}, {index: {_id: 43, data: {}}}]
194
- DummiesIndex::Dummy.bulk body: [{index: {_id: 43, data: {}}}, {index: {_id: 44, data: {}}}]
195
- end.to update_index(DummiesIndex::Dummy).and_reindex(42, times: 3).and_reindex(44, 43, times: 4) end
190
+ DummiesIndex.bulk body: [{index: {_id: 42, data: {}}}, {index: {_id: 43, data: {}}}]
191
+ DummiesIndex.bulk body: [{index: {_id: 43, data: {}}}, {index: {_id: 44, data: {}}}]
192
+ end.to update_index(DummiesIndex).and_reindex(42, times: 3).and_reindex(44, 43, times: 4)
193
+ end
196
194
  end
197
195
 
198
196
  specify { expectation.to fail_matching 'Expected document with id `44` to be reindexed' }
@@ -205,20 +203,23 @@ describe :update_index do
205
203
  context ':with' do
206
204
  specify do
207
205
  expect do
208
- DummiesIndex::Dummy.bulk body: [{index: {_id: 42, data: {a: '1'}}}, {index: {_id: 42, data: {'a' => 2}}}]
209
- end.to update_index(DummiesIndex::Dummy).and_reindex(42, with: {a: 2}) end
206
+ DummiesIndex.bulk body: [{index: {_id: 42, data: {a: '1'}}}, {index: {_id: 42, data: {'a' => 2}}}]
207
+ end.to update_index(DummiesIndex).and_reindex(42, with: {a: 2})
208
+ end
210
209
 
211
210
  specify do
212
211
  expect do
213
- DummiesIndex::Dummy.bulk body: [{index: {_id: 42, data: {a: '1'}}}, {index: {_id: 42, data: {'b' => 2}}}]
214
- end.to update_index(DummiesIndex::Dummy).and_reindex(42, with: {a: '1', b: 2}) end
212
+ DummiesIndex.bulk body: [{index: {_id: 42, data: {a: '1'}}}, {index: {_id: 42, data: {'b' => 2}}}]
213
+ end.to update_index(DummiesIndex).and_reindex(42, with: {a: '1', b: 2})
214
+ end
215
215
 
216
216
  specify do
217
217
  expect do
218
218
  expect do
219
- DummiesIndex::Dummy.bulk body: [{index: {_id: 43, data: {a: '1'}}}]
220
- end.to update_index(DummiesIndex::Dummy).and_reindex(42, with: {a: 1})
221
- end.to fail_matching('Expected document with id `42` to be reindexed, but it was not') end
219
+ DummiesIndex.bulk body: [{index: {_id: 43, data: {a: '1'}}}]
220
+ end.to update_index(DummiesIndex).and_reindex(42, with: {a: 1})
221
+ end.to fail_matching('Expected document with id `42` to be reindexed, but it was not')
222
+ end
222
223
 
223
224
  [
224
225
  [{a: %w[one two]}, {a: %w[one two]}],
@@ -229,8 +230,9 @@ describe :update_index do
229
230
  ].each do |(data, with)|
230
231
  specify do
231
232
  expect do
232
- DummiesIndex::Dummy.bulk body: [{index: {_id: 42, data: data}}]
233
- end.to update_index(DummiesIndex::Dummy).and_reindex(42, with: with) end
233
+ DummiesIndex.bulk body: [{index: {_id: 42, data: data}}]
234
+ end.to update_index(DummiesIndex).and_reindex(42, with: with)
235
+ end
234
236
  end
235
237
 
236
238
  [
@@ -243,17 +245,19 @@ describe :update_index do
243
245
  specify do
244
246
  expect do
245
247
  expect do
246
- DummiesIndex::Dummy.bulk body: [{index: {_id: 42, data: data}}]
247
- end.to update_index(DummiesIndex::Dummy).and_reindex(42, with: with)
248
- end.to fail_matching('Expected document with id `42` to be reindexed') end
248
+ DummiesIndex.bulk body: [{index: {_id: 42, data: data}}]
249
+ end.to update_index(DummiesIndex).and_reindex(42, with: with)
250
+ end.to fail_matching('Expected document with id `42` to be reindexed')
251
+ end
249
252
  end
250
253
 
251
254
  context do
252
255
  let(:expectation) do
253
256
  expect do
254
257
  expect do
255
- DummiesIndex::Dummy.bulk body: [{index: {_id: 43, data: {a: '1'}}}, {index: {_id: 42, data: {'a' => 2}}}]
256
- end.to update_index(DummiesIndex::Dummy).and_reindex(43, times: 2, with: {a: 2}) end
258
+ DummiesIndex.bulk body: [{index: {_id: 43, data: {a: '1'}}}, {index: {_id: 42, data: {'a' => 2}}}]
259
+ end.to update_index(DummiesIndex).and_reindex(43, times: 2, with: {a: 2})
260
+ end
257
261
  end
258
262
 
259
263
  specify { expectation.to fail_matching 'Expected document with id `43` to be reindexed' }
@@ -265,27 +269,27 @@ describe :update_index do
265
269
 
266
270
  context '#and_delete' do
267
271
  specify do
268
- expect { DummiesIndex::Dummy.bulk body: [{index: {_id: 42, data: {}}}, {delete: {_id: 43}}] }
269
- .to update_index(DummiesIndex::Dummy).and_reindex(42).and_delete(double(id: 43))
272
+ expect { DummiesIndex.bulk body: [{index: {_id: 42, data: {}}}, {delete: {_id: 43}}] }
273
+ .to update_index(DummiesIndex).and_reindex(42).and_delete(double(id: 43))
270
274
  end
271
275
  specify do
272
- expect { DummiesIndex::Dummy.bulk body: [{delete: {_id: 42}}, {delete: {_id: 43}}] }
273
- .to update_index(DummiesIndex::Dummy).and_delete(42).and_delete(double(id: 43))
276
+ expect { DummiesIndex.bulk body: [{delete: {_id: 42}}, {delete: {_id: 43}}] }
277
+ .to update_index(DummiesIndex).and_delete(42).and_delete(double(id: 43))
274
278
  end
275
279
  specify do
276
- expect { DummiesIndex::Dummy.bulk body: [{delete: {_id: 42}}, {delete: {_id: 43}}] }
277
- .to update_index(DummiesIndex::Dummy).and_delete(42, double(id: 43))
280
+ expect { DummiesIndex.bulk body: [{delete: {_id: 42}}, {delete: {_id: 43}}] }
281
+ .to update_index(DummiesIndex).and_delete(42, double(id: 43))
278
282
  end
279
283
  specify do
280
- expect { DummiesIndex::Dummy.bulk body: [{delete: {_id: 42}}, {delete: {_id: 43}}] }
281
- .to update_index(DummiesIndex::Dummy).and_delete([43, double(id: 42)])
284
+ expect { DummiesIndex.bulk body: [{delete: {_id: 42}}, {delete: {_id: 43}}] }
285
+ .to update_index(DummiesIndex).and_delete([43, double(id: 42)])
282
286
  end
283
287
 
284
288
  context do
285
289
  let(:expectation) do
286
290
  expect do
287
- expect { DummiesIndex::Dummy.bulk body: [{index: {_id: 42, data: {}}}, {delete: {_id: 43}}] }
288
- .to update_index(DummiesIndex::Dummy).and_reindex(43).and_delete(double(id: 42))
291
+ expect { DummiesIndex.bulk body: [{index: {_id: 42, data: {}}}, {delete: {_id: 43}}] }
292
+ .to update_index(DummiesIndex).and_reindex(43).and_delete(double(id: 42))
289
293
  end
290
294
  end
291
295
 
@@ -296,8 +300,8 @@ describe :update_index do
296
300
  context do
297
301
  let(:expectation) do
298
302
  expect do
299
- expect { DummiesIndex::Dummy.bulk body: [{delete: {_id: 42, data: {}}}, {delete: {_id: 42}}] }
300
- .to update_index(DummiesIndex::Dummy).and_delete(44, times: 2).and_delete(double(id: 42), times: 3)
303
+ expect { DummiesIndex.bulk body: [{delete: {_id: 42, data: {}}}, {delete: {_id: 42}}] }
304
+ .to update_index(DummiesIndex).and_delete(44, times: 2).and_delete(double(id: 42), times: 3)
301
305
  end
302
306
  end
303
307
 
@@ -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 >= '2.4' }
7
- specify { expect(described_class.version).to be < '6.0' }
6
+ specify { expect(described_class.version).to be >= '7.0' }
7
+ specify { expect(described_class.version).to be < '8.0' }
8
8
  end
9
9
  end
@@ -8,17 +8,15 @@ describe Chewy::Search::Loader do
8
8
  stub_model(:country)
9
9
 
10
10
  stub_index(:cities) do
11
- define_type City do
12
- field :name
13
- field :rating, type: 'integer'
14
- end
11
+ index_scope City
12
+ field :name
13
+ field :rating, type: 'integer'
15
14
  end
16
15
 
17
16
  stub_index(:countries) do
18
- define_type Country do
19
- field :name
20
- field :rating, type: 'integer'
21
- end
17
+ index_scope Country
18
+ field :name
19
+ field :rating, type: 'integer'
22
20
  end
23
21
  end
24
22
 
@@ -33,19 +31,18 @@ describe Chewy::Search::Loader do
33
31
  let(:options) { {} }
34
32
  subject { described_class.new(indexes: [CitiesIndex, CountriesIndex], **options) }
35
33
 
36
- describe '#derive_type' do
37
- specify { expect(subject.derive_type('cities', 'city')).to eq(CitiesIndex::City) }
38
- specify { expect(subject.derive_type('cities_suffix', 'city')).to eq(CitiesIndex::City) }
34
+ describe '#derive_index' do
35
+ specify { expect(subject.derive_index('cities')).to eq(CitiesIndex) }
36
+ specify { expect(subject.derive_index('cities_suffix')).to eq(CitiesIndex) }
39
37
 
40
- specify { expect { subject.derive_type('cities', 'place') }.to raise_error(Chewy::UnderivableType) }
41
- specify { expect { subject.derive_type('whatever', 'city') }.to raise_error(Chewy::UnderivableType) }
42
- specify { expect { subject.derive_type('citiessuffix', 'city') }.to raise_error(Chewy::UnderivableType) }
38
+ specify { expect { subject.derive_index('whatever') }.to raise_error(Chewy::UndefinedIndex) }
39
+ specify { expect { subject.derive_index('citiessuffix') }.to raise_error(Chewy::UndefinedIndex) }
43
40
 
44
41
  context do
45
42
  before { CitiesIndex.index_name :boro_goves }
46
43
 
47
- specify { expect(subject.derive_type('boro_goves', 'city')).to eq(CitiesIndex::City) }
48
- specify { expect(subject.derive_type('boro_goves_suffix', 'city')).to eq(CitiesIndex::City) }
44
+ specify { expect(subject.derive_index('boro_goves')).to eq(CitiesIndex) }
45
+ specify { expect(subject.derive_index('boro_goves_suffix')).to eq(CitiesIndex) }
49
46
  end
50
47
  end
51
48
 
@@ -54,21 +51,6 @@ describe Chewy::Search::Loader do
54
51
 
55
52
  specify { expect(subject.load(hits)).to eq([*cities, *countries]) }
56
53
 
57
- context do
58
- let(:options) { {only: 'city'} }
59
- specify { expect(subject.load(hits)).to eq([*cities, nil, nil]) }
60
- end
61
-
62
- context do
63
- let(:options) { {except: 'city'} }
64
- specify { expect(subject.load(hits)).to eq([nil, nil, *countries]) }
65
- end
66
-
67
- context do
68
- let(:options) { {except: %w[city country]} }
69
- specify { expect(subject.load(hits)).to eq([nil, nil, nil, nil]) }
70
- end
71
-
72
54
  context 'scopes', :active_record do
73
55
  context do
74
56
  let(:options) { {scope: -> { where('rating > 2') }} }
@@ -76,19 +58,7 @@ describe Chewy::Search::Loader do
76
58
  end
77
59
 
78
60
  context do
79
- let(:options) { {country: {scope: -> { where('rating > 2') }}} }
80
- specify { expect(subject.load(hits)).to eq([*cities, nil, countries.last]) }
81
- end
82
- end
83
-
84
- context 'scopes', :mongoid do
85
- context do
86
- let(:options) { {scope: -> { where(:rating.gt => 2) }} }
87
- specify { expect(subject.load(hits)).to eq([nil, nil, nil, countries.last]) }
88
- end
89
-
90
- context do
91
- let(:options) { {country: {scope: -> { where(:rating.gt => 2) }}} }
61
+ let(:options) { {countries: {scope: -> { where('rating > 2') }}} }
92
62
  specify { expect(subject.load(hits)).to eq([*cities, nil, countries.last]) }
93
63
  end
94
64
  end
@@ -96,21 +66,17 @@ describe Chewy::Search::Loader do
96
66
  context 'objects' do
97
67
  before do
98
68
  stub_index(:cities) do
99
- define_type :city do
100
- field :name
101
- field :rating, type: 'integer'
102
- end
69
+ field :name
70
+ field :rating, type: 'integer'
103
71
  end
104
72
 
105
73
  stub_index(:countries) do
106
- define_type :country do
107
- field :name
108
- field :rating, type: 'integer'
109
- end
74
+ field :name
75
+ field :rating, type: 'integer'
110
76
  end
111
77
  end
112
78
 
113
- specify { expect(subject.load(hits).map(&:class).uniq).to eq([CitiesIndex::City, CountriesIndex::Country]) }
79
+ specify { expect(subject.load(hits).map(&:class).uniq).to eq([CitiesIndex, CountriesIndex]) }
114
80
  specify { expect(subject.load(hits).map(&:rating)).to eq([*cities, *countries].map(&:rating)) }
115
81
  end
116
82
  end
@@ -5,10 +5,8 @@ shared_examples :kaminari do |request_base_class|
5
5
 
6
6
  before do
7
7
  stub_index(:products) do
8
- define_type(:product) do
9
- field :name
10
- field :age, type: 'integer'
11
- end
8
+ field :name
9
+ field :age, type: 'integer'
12
10
  end
13
11
  end
14
12
 
@@ -25,7 +23,7 @@ shared_examples :kaminari do |request_base_class|
25
23
  context do
26
24
  let(:data) { Array.new(10) { |i| {id: i.next.to_s, name: "Name#{i.next}", age: 10 * i.next}.stringify_keys! } }
27
25
 
28
- before { ProductsIndex::Product.import!(data.map { |h| double(h) }) }
26
+ before { ProductsIndex.import!(data.map { |h| double(h) }) }
29
27
  before { allow(::Kaminari.config).to receive_messages(default_per_page: 3) }
30
28
 
31
29
  describe '#per, #page' do
@@ -5,7 +5,7 @@ describe Chewy::Search::Pagination::Kaminari do
5
5
  describe '#objects' do
6
6
  let(:data) { Array.new(12) { |i| {id: i.next.to_s, name: "Name#{i.next}", age: 10 * i.next}.stringify_keys! } }
7
7
 
8
- before { ProductsIndex::Product.import!(data.map { |h| double(h) }) }
8
+ before { ProductsIndex.import!(data.map { |h| double(h) }) }
9
9
  before { allow(::Kaminari.config).to receive_messages(default_per_page: 17) }
10
10
 
11
11
  specify { expect(search.objects.class).to eq(Kaminari::PaginatableArray) }
@@ -0,0 +1,5 @@
1
+ require 'chewy/search/parameters/hash_storage_examples'
2
+
3
+ describe Chewy::Search::Parameters::Collapse do
4
+ it_behaves_like :hash_storage, :collapse
5
+ end