chewy 5.0.0 → 7.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (147) hide show
  1. checksums.yaml +4 -4
  2. data/.circleci/config.yml +240 -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 +94 -0
  7. data/Appraisals +1 -17
  8. data/CHANGELOG.md +308 -356
  9. data/CODE_OF_CONDUCT.md +14 -0
  10. data/CONTRIBUTING.md +63 -0
  11. data/Gemfile +2 -0
  12. data/LICENSE.txt +1 -1
  13. data/README.md +71 -55
  14. data/chewy.gemspec +5 -5
  15. data/gemfiles/rails.5.2.activerecord.gemfile +4 -3
  16. data/gemfiles/{rails.5.0.activerecord.gemfile → rails.5.2.mongoid.6.4.gemfile} +4 -3
  17. data/gemfiles/{rails.5.0.mongoid.6.1.gemfile → rails.6.0.activerecord.gemfile} +4 -3
  18. data/gemfiles/{rails.5.1.activerecord.gemfile → rails.6.1.activerecord.gemfile} +6 -3
  19. data/lib/chewy.rb +1 -1
  20. data/lib/chewy/backports/duplicable.rb +1 -1
  21. data/lib/chewy/config.rb +2 -20
  22. data/lib/chewy/fields/base.rb +1 -7
  23. data/lib/chewy/fields/root.rb +2 -2
  24. data/lib/chewy/index.rb +2 -0
  25. data/lib/chewy/index/actions.rb +15 -5
  26. data/lib/chewy/index/aliases.rb +16 -5
  27. data/lib/chewy/multi_search.rb +62 -0
  28. data/lib/chewy/railtie.rb +1 -1
  29. data/lib/chewy/search.rb +2 -9
  30. data/lib/chewy/search/loader.rb +1 -1
  31. data/lib/chewy/search/pagination/will_paginate.rb +1 -1
  32. data/lib/chewy/search/parameters.rb +24 -6
  33. data/lib/chewy/search/parameters/allow_partial_search_results.rb +27 -0
  34. data/lib/chewy/search/parameters/indices.rb +123 -0
  35. data/lib/chewy/search/parameters/none.rb +1 -3
  36. data/lib/chewy/search/request.rb +101 -74
  37. data/lib/chewy/search/scrolling.rb +7 -6
  38. data/lib/chewy/stash.rb +1 -1
  39. data/lib/chewy/strategy/active_job.rb +1 -1
  40. data/lib/chewy/strategy/sidekiq.rb +1 -1
  41. data/lib/chewy/type.rb +4 -1
  42. data/lib/chewy/type/adapter/active_record.rb +1 -1
  43. data/lib/chewy/type/adapter/mongoid.rb +1 -1
  44. data/lib/chewy/type/adapter/orm.rb +7 -4
  45. data/lib/chewy/type/adapter/sequel.rb +1 -1
  46. data/lib/chewy/type/import.rb +14 -4
  47. data/lib/chewy/type/import/bulk_request.rb +4 -2
  48. data/lib/chewy/type/import/journal_builder.rb +1 -1
  49. data/lib/chewy/type/import/routine.rb +1 -1
  50. data/lib/chewy/type/mapping.rb +4 -4
  51. data/lib/chewy/type/observe.rb +3 -3
  52. data/lib/chewy/type/syncer.rb +4 -5
  53. data/lib/chewy/type/witchcraft.rb +4 -2
  54. data/lib/chewy/type/wrapper.rb +12 -2
  55. data/lib/chewy/version.rb +1 -1
  56. data/migration_guide.md +56 -0
  57. data/spec/chewy/config_spec.rb +1 -22
  58. data/spec/chewy/fields/base_spec.rb +11 -9
  59. data/spec/chewy/index/actions_spec.rb +120 -33
  60. data/spec/chewy/index/aliases_spec.rb +3 -3
  61. data/spec/chewy/index_spec.rb +16 -39
  62. data/spec/chewy/journal_spec.rb +22 -18
  63. data/spec/chewy/minitest/search_index_receiver_spec.rb +11 -9
  64. data/spec/chewy/multi_search_spec.rb +85 -0
  65. data/spec/chewy/rake_helper_spec.rb +102 -87
  66. data/spec/chewy/rspec/update_index_spec.rb +47 -46
  67. data/spec/chewy/runtime_spec.rb +2 -2
  68. data/spec/chewy/search/parameters/indices_spec.rb +190 -0
  69. data/spec/chewy/search/parameters/none_spec.rb +1 -1
  70. data/spec/chewy/search/parameters_spec.rb +21 -4
  71. data/spec/chewy/search/request_spec.rb +103 -70
  72. data/spec/chewy/search/response_spec.rb +27 -17
  73. data/spec/chewy/search/scrolling_spec.rb +27 -17
  74. data/spec/chewy/search_spec.rb +45 -41
  75. data/spec/chewy/stash_spec.rb +14 -12
  76. data/spec/chewy/strategy/active_job_spec.rb +15 -2
  77. data/spec/chewy/strategy/shoryuken_spec.rb +6 -2
  78. data/spec/chewy/strategy/sidekiq_spec.rb +6 -2
  79. data/spec/chewy/type/adapter/active_record_spec.rb +16 -4
  80. data/spec/chewy/type/import/bulk_builder_spec.rb +9 -94
  81. data/spec/chewy/type/import/journal_builder_spec.rb +9 -7
  82. data/spec/chewy/type/import_spec.rb +9 -0
  83. data/spec/chewy/type/mapping_spec.rb +3 -1
  84. data/spec/chewy/type/observe_spec.rb +4 -4
  85. data/spec/chewy/type/witchcraft_spec.rb +15 -0
  86. data/spec/chewy/type/wrapper_spec.rb +3 -1
  87. data/spec/chewy_spec.rb +0 -7
  88. data/spec/spec_helper.rb +4 -8
  89. data/spec/support/active_record.rb +21 -0
  90. metadata +32 -97
  91. data/.travis.yml +0 -45
  92. data/LEGACY_DSL.md +0 -497
  93. data/gemfiles/rails.4.0.activerecord.gemfile +0 -15
  94. data/gemfiles/rails.4.1.activerecord.gemfile +0 -15
  95. data/gemfiles/rails.4.2.activerecord.gemfile +0 -16
  96. data/gemfiles/rails.4.2.mongoid.5.2.gemfile +0 -16
  97. data/gemfiles/rails.5.1.mongoid.6.3.gemfile +0 -16
  98. data/lib/chewy/query.rb +0 -1137
  99. data/lib/chewy/query/compose.rb +0 -68
  100. data/lib/chewy/query/criteria.rb +0 -191
  101. data/lib/chewy/query/filters.rb +0 -244
  102. data/lib/chewy/query/loading.rb +0 -110
  103. data/lib/chewy/query/nodes/and.rb +0 -25
  104. data/lib/chewy/query/nodes/base.rb +0 -17
  105. data/lib/chewy/query/nodes/bool.rb +0 -34
  106. data/lib/chewy/query/nodes/equal.rb +0 -34
  107. data/lib/chewy/query/nodes/exists.rb +0 -20
  108. data/lib/chewy/query/nodes/expr.rb +0 -28
  109. data/lib/chewy/query/nodes/field.rb +0 -110
  110. data/lib/chewy/query/nodes/has_child.rb +0 -15
  111. data/lib/chewy/query/nodes/has_parent.rb +0 -15
  112. data/lib/chewy/query/nodes/has_relation.rb +0 -59
  113. data/lib/chewy/query/nodes/match_all.rb +0 -11
  114. data/lib/chewy/query/nodes/missing.rb +0 -20
  115. data/lib/chewy/query/nodes/not.rb +0 -25
  116. data/lib/chewy/query/nodes/or.rb +0 -25
  117. data/lib/chewy/query/nodes/prefix.rb +0 -19
  118. data/lib/chewy/query/nodes/query.rb +0 -20
  119. data/lib/chewy/query/nodes/range.rb +0 -63
  120. data/lib/chewy/query/nodes/raw.rb +0 -15
  121. data/lib/chewy/query/nodes/regexp.rb +0 -35
  122. data/lib/chewy/query/nodes/script.rb +0 -20
  123. data/lib/chewy/query/pagination.rb +0 -25
  124. data/spec/chewy/query/criteria_spec.rb +0 -700
  125. data/spec/chewy/query/filters_spec.rb +0 -201
  126. data/spec/chewy/query/loading_spec.rb +0 -124
  127. data/spec/chewy/query/nodes/and_spec.rb +0 -12
  128. data/spec/chewy/query/nodes/bool_spec.rb +0 -14
  129. data/spec/chewy/query/nodes/equal_spec.rb +0 -32
  130. data/spec/chewy/query/nodes/exists_spec.rb +0 -18
  131. data/spec/chewy/query/nodes/has_child_spec.rb +0 -59
  132. data/spec/chewy/query/nodes/has_parent_spec.rb +0 -59
  133. data/spec/chewy/query/nodes/match_all_spec.rb +0 -11
  134. data/spec/chewy/query/nodes/missing_spec.rb +0 -16
  135. data/spec/chewy/query/nodes/not_spec.rb +0 -14
  136. data/spec/chewy/query/nodes/or_spec.rb +0 -12
  137. data/spec/chewy/query/nodes/prefix_spec.rb +0 -16
  138. data/spec/chewy/query/nodes/query_spec.rb +0 -12
  139. data/spec/chewy/query/nodes/range_spec.rb +0 -32
  140. data/spec/chewy/query/nodes/raw_spec.rb +0 -11
  141. data/spec/chewy/query/nodes/regexp_spec.rb +0 -43
  142. data/spec/chewy/query/nodes/script_spec.rb +0 -15
  143. data/spec/chewy/query/pagination/kaminari_spec.rb +0 -5
  144. data/spec/chewy/query/pagination/will_paginate_spec.rb +0 -5
  145. data/spec/chewy/query/pagination_spec.rb +0 -39
  146. data/spec/chewy/query_spec.rb +0 -637
  147. data/spec/chewy/search/parameters/indices_boost_spec.rb +0 -83
@@ -10,13 +10,13 @@ describe Chewy::Index::Aliases do
10
10
 
11
11
  context do
12
12
  before { DummiesIndex.create! }
13
- specify { expect(DummiesIndex.indexes).to eq([]) }
13
+ specify { expect(DummiesIndex.indexes).to eq(['dummies']) }
14
14
  end
15
15
 
16
16
  context do
17
17
  before { DummiesIndex.create! }
18
18
  before { Chewy.client.indices.put_alias index: 'dummies', name: 'dummies_2013' }
19
- specify { expect(DummiesIndex.indexes).to eq([]) }
19
+ specify { expect(DummiesIndex.indexes).to eq(['dummies']) }
20
20
  end
21
21
 
22
22
  context do
@@ -43,7 +43,7 @@ describe Chewy::Index::Aliases do
43
43
 
44
44
  context do
45
45
  before { DummiesIndex.create! '2013' }
46
- specify { expect(DummiesIndex.aliases).to eq([]) }
46
+ specify { expect(DummiesIndex.aliases).to eq(['dummies']) }
47
47
  end
48
48
  end
49
49
  end
@@ -12,8 +12,11 @@ describe Chewy::Index do
12
12
  stub_model(:city)
13
13
  stub_model(:country)
14
14
 
15
- stub_index(:places) do
15
+ stub_index(:cities) do
16
16
  define_type City
17
+ end
18
+
19
+ stub_index(:countries) do
17
20
  define_type Country
18
21
  end
19
22
  end
@@ -22,23 +25,23 @@ describe Chewy::Index do
22
25
  let!(:countries) { Array.new(2) { |i| Country.create! id: i + 1 } }
23
26
 
24
27
  specify do
25
- expect { PlacesIndex.import }.to update_index(PlacesIndex::City).and_reindex(cities)
26
- expect { PlacesIndex.import }.to update_index(PlacesIndex::Country).and_reindex(countries)
28
+ expect { CitiesIndex.import }.to update_index(CitiesIndex).and_reindex(cities)
29
+ expect { CountriesIndex.import }.to update_index(CountriesIndex).and_reindex(countries)
27
30
  end
28
31
 
29
32
  specify do
30
- expect { PlacesIndex.import city: cities.first }.to update_index(PlacesIndex::City).and_reindex(cities.first).only
31
- expect { PlacesIndex.import city: cities.first }.to update_index(PlacesIndex::Country).and_reindex(countries)
33
+ expect { CitiesIndex.import city: cities.first }.to update_index(CitiesIndex).and_reindex(cities.first).only
34
+ expect { CountriesIndex.import city: cities.first }.to update_index(CountriesIndex).and_reindex(countries)
32
35
  end
33
36
 
34
37
  specify do
35
- expect { PlacesIndex.import city: cities.first, country: countries.last }.to update_index(PlacesIndex::City).and_reindex(cities.first).only
36
- expect { PlacesIndex.import city: cities.first, country: countries.last }.to update_index(PlacesIndex::Country).and_reindex(countries.last).only
38
+ expect { CitiesIndex.import city: cities.first, country: countries.last }.to update_index(CitiesIndex).and_reindex(cities.first).only
39
+ expect { CountriesIndex.import city: cities.first, country: countries.last }.to update_index(CountriesIndex).and_reindex(countries.last).only
37
40
  end
38
41
 
39
42
  specify do
40
- expect(PlacesIndex.client).to receive(:bulk).with(hash_including(refresh: false)).twice
41
- PlacesIndex.import city: cities.first, refresh: false
43
+ expect(CitiesIndex.client).to receive(:bulk).with(hash_including(refresh: false)).once
44
+ CitiesIndex.import city: cities.first, refresh: false
42
45
  end
43
46
  end
44
47
 
@@ -101,43 +104,27 @@ describe Chewy::Index do
101
104
 
102
105
  context do
103
106
  before { stub_class('City') }
104
- before { stub_class('City::District', City) }
107
+ before { stub_class('Country') }
105
108
 
106
109
  specify do
107
110
  expect do
108
111
  Kernel.eval <<-DUMMY_CITY_INDEX
109
- class DummyCityIndex < Chewy::Index
112
+ class DummyCityIndex2 < Chewy::Index
110
113
  define_type City
111
- define_type City::District
114
+ define_type Country
112
115
  end
113
116
  DUMMY_CITY_INDEX
114
- end.not_to raise_error
115
- end
117
+ end.to raise_error(/Multiple types are deprecated/)
116
118
 
117
- specify do
118
119
  expect do
119
120
  Kernel.eval <<-DUMMY_CITY_INDEX
120
121
  class DummyCityIndex2 < Chewy::Index
121
- define_type City
122
122
  define_type City::Nothing
123
123
  end
124
124
  DUMMY_CITY_INDEX
125
125
  end.to raise_error(NameError)
126
126
  end
127
127
  end
128
-
129
- context 'type methods should be deprecated and can\'t redefine existing ones' do
130
- before do
131
- stub_index(:places) do
132
- def self.city; end
133
- define_type :city
134
- define_type :country
135
- end
136
- end
137
-
138
- specify { expect(PlacesIndex.city).to be_nil }
139
- specify { expect(PlacesIndex::Country).to be < Chewy::Type }
140
- end
141
128
  end
142
129
 
143
130
  describe '.type_hash' do
@@ -248,16 +235,6 @@ describe Chewy::Index do
248
235
  end
249
236
  end.mappings_hash).to eq(mappings: {document: {properties: {date: {type: 'date'}}}})
250
237
  end
251
- specify do
252
- expect(stub_index(:documents) do
253
- define_type :document do
254
- field :name
255
- end
256
- define_type :document2 do
257
- field :name
258
- end
259
- end.mappings_hash[:mappings].keys).to match_array(%i[document document2])
260
- end
261
238
  end
262
239
 
263
240
  describe '.specification_hash' do
@@ -6,16 +6,18 @@ describe Chewy::Journal do
6
6
  context namespace.present? ? 'with namespace' : 'without namespace' do
7
7
  before do
8
8
  stub_model(:city) do
9
- update_index "#{namespace}places#city", :self
9
+ update_index "#{namespace}cities", :self
10
10
  end
11
11
  stub_model(:country) do
12
- update_index "#{namespace}places#country", :self
12
+ update_index "#{namespace}countries", :self
13
13
  end
14
14
 
15
- stub_index("#{namespace}places") do
15
+ stub_index("#{namespace}cities") do
16
16
  define_type City do
17
17
  default_import_options journal: true
18
18
  end
19
+ end
20
+ stub_index("#{namespace}countries") do
19
21
  define_type Country do
20
22
  default_import_options journal: true
21
23
  end
@@ -41,7 +43,8 @@ describe Chewy::Journal do
41
43
  end
42
44
 
43
45
  specify do
44
- places_index = namespace.present? ? Namespace::PlacesIndex : PlacesIndex
46
+ cities_index = namespace.present? ? Namespace::CitiesIndex : CitiesIndex
47
+ countries_index = namespace.present? ? Namespace::CountriesIndex : CountriesIndex
45
48
  Chewy.strategy(:urgent) do
46
49
  cities = Array.new(2) { |i| City.create!(id: i + 1) }
47
50
  countries = Array.new(2) { |i| Country.create!(id: i + 1) }
@@ -49,12 +52,13 @@ describe Chewy::Journal do
49
52
 
50
53
  Timecop.freeze(import_time)
51
54
 
52
- places_index.import
55
+ cities_index.import
56
+ countries_index.import
53
57
 
54
58
  expect(Chewy::Stash::Journal.exists?).to eq true
55
59
 
56
60
  Timecop.freeze(update_time)
57
- cities.first.update_attributes!(name: 'Supername')
61
+ cities.first.update!(name: 'Supername')
58
62
 
59
63
  Timecop.freeze(destroy_time)
60
64
  countries.last.destroy
@@ -62,63 +66,63 @@ describe Chewy::Journal do
62
66
  journal_entries = Chewy::Stash::Journal.order(:created_at).hits.map { |r| r['_source'] }
63
67
  expected_journal = [
64
68
  {
65
- 'index_name' => "#{namespace}places",
69
+ 'index_name' => "#{namespace}cities",
66
70
  'type_name' => 'city',
67
71
  'action' => 'index',
68
72
  'references' => ['1'].map(&Base64.method(:encode64)),
69
73
  'created_at' => time.utc.as_json
70
74
  },
71
75
  {
72
- 'index_name' => "#{namespace}places",
76
+ 'index_name' => "#{namespace}cities",
73
77
  'type_name' => 'city',
74
78
  'action' => 'index',
75
79
  'references' => ['2'].map(&Base64.method(:encode64)),
76
80
  'created_at' => time.utc.as_json
77
81
  },
78
82
  {
79
- 'index_name' => "#{namespace}places",
83
+ 'index_name' => "#{namespace}countries",
80
84
  'type_name' => 'country',
81
85
  'action' => 'index',
82
86
  'references' => ['1'].map(&Base64.method(:encode64)),
83
87
  'created_at' => time.utc.as_json
84
88
  },
85
89
  {
86
- 'index_name' => "#{namespace}places",
90
+ 'index_name' => "#{namespace}countries",
87
91
  'type_name' => 'country',
88
92
  'action' => 'index',
89
93
  'references' => ['2'].map(&Base64.method(:encode64)),
90
94
  'created_at' => time.utc.as_json
91
95
  },
92
96
  {
93
- 'index_name' => "#{namespace}places",
97
+ 'index_name' => "#{namespace}countries",
94
98
  'type_name' => 'country',
95
99
  'action' => 'index',
96
100
  'references' => ['3'].map(&Base64.method(:encode64)),
97
101
  'created_at' => time.utc.as_json
98
102
  },
99
103
  {
100
- 'index_name' => "#{namespace}places",
104
+ 'index_name' => "#{namespace}cities",
101
105
  'type_name' => 'city',
102
106
  'action' => 'index',
103
107
  'references' => %w[1 2].map(&Base64.method(:encode64)),
104
108
  'created_at' => import_time.utc.as_json
105
109
  },
106
110
  {
107
- 'index_name' => "#{namespace}places",
111
+ 'index_name' => "#{namespace}countries",
108
112
  'type_name' => 'country',
109
113
  'action' => 'index',
110
114
  'references' => %w[1 2 3].map(&Base64.method(:encode64)),
111
115
  'created_at' => import_time.utc.as_json
112
116
  },
113
117
  {
114
- 'index_name' => "#{namespace}places",
118
+ 'index_name' => "#{namespace}cities",
115
119
  'type_name' => 'city',
116
120
  'action' => 'index',
117
121
  'references' => ['1'].map(&Base64.method(:encode64)),
118
122
  'created_at' => update_time.utc.as_json
119
123
  },
120
124
  {
121
- 'index_name' => "#{namespace}places",
125
+ 'index_name' => "#{namespace}countries",
122
126
  'type_name' => 'country',
123
127
  'action' => 'delete',
124
128
  'references' => ['2'].map(&Base64.method(:encode64)),
@@ -133,11 +137,11 @@ describe Chewy::Journal do
133
137
  expect(journal_entries.size).to eq 4
134
138
 
135
139
  # simulate lost data
136
- Chewy.client.delete(index: "#{Chewy.settings[:prefix]}_places", type: 'city', id: 1, refresh: true)
137
- expect(places_index::City.count).to eq 1
140
+ Chewy.client.delete(index: "#{Chewy.settings[:prefix]}_cities", type: 'city', id: 1, refresh: true)
141
+ expect(cities_index.count).to eq 1
138
142
 
139
143
  described_class.new.apply(time)
140
- expect(places_index::City.count).to eq 2
144
+ expect(cities_index.count).to eq 2
141
145
 
142
146
  clean_response = described_class.new.clean(import_time)
143
147
  expect(clean_response['deleted'] || clean_response['_indices']['_all']['deleted']).to eq 7
@@ -29,7 +29,9 @@ describe :search_index_receiver do
29
29
  define_type :fizz do
30
30
  root value: ->(_o) { {} }
31
31
  end
32
+ end
32
33
 
34
+ stub_index(:dummies2) do
33
35
  define_type :buzz do
34
36
  root value: ->(_o) { {} }
35
37
  end
@@ -39,15 +41,15 @@ describe :search_index_receiver do
39
41
  context 'catch' do
40
42
  specify 'archives more than one type' do
41
43
  receiver.catch search_request(2), DummiesIndex::Fizz
42
- receiver.catch search_request(3), DummiesIndex::Buzz
43
- expect(receiver.indexes.keys).to match_array([DummiesIndex::Fizz, DummiesIndex::Buzz])
44
+ receiver.catch search_request(3), Dummies2Index::Buzz
45
+ expect(receiver.indexes.keys).to match_array([DummiesIndex::Fizz, Dummies2Index::Buzz])
44
46
  end
45
47
  end
46
48
 
47
49
  context 'indexes_for' do
48
50
  before do
49
51
  receiver.catch search_request(2), DummiesIndex::Fizz
50
- receiver.catch search_request(3), DummiesIndex::Buzz
52
+ receiver.catch search_request(3), Dummies2Index::Buzz
51
53
  end
52
54
 
53
55
  specify 'returns indexes for a specific type' do
@@ -56,7 +58,7 @@ describe :search_index_receiver do
56
58
 
57
59
  specify 'returns only indexes for all types' do
58
60
  index_responses = receiver.indexes
59
- expect(index_responses.keys).to match_array([DummiesIndex::Fizz, DummiesIndex::Buzz])
61
+ expect(index_responses.keys).to match_array([DummiesIndex::Fizz, Dummies2Index::Buzz])
60
62
  expect(parse_request(index_responses.values.flatten)).to match_array([1, 2, 1, 2, 3])
61
63
  end
62
64
  end
@@ -64,16 +66,16 @@ describe :search_index_receiver do
64
66
  context 'deletes_for' do
65
67
  before do
66
68
  receiver.catch search_request(2, verb: :delete), DummiesIndex::Fizz
67
- receiver.catch search_request(3, verb: :delete), DummiesIndex::Buzz
69
+ receiver.catch search_request(3, verb: :delete), Dummies2Index::Buzz
68
70
  end
69
71
 
70
72
  specify 'returns deletes for a specific type' do
71
- expect(receiver.deletes_for(DummiesIndex::Buzz)).to match_array([1, 2, 3])
73
+ expect(receiver.deletes_for(Dummies2Index::Buzz)).to match_array([1, 2, 3])
72
74
  end
73
75
 
74
76
  specify 'returns only deletes for all types' do
75
77
  deletes = receiver.deletes
76
- expect(deletes.keys).to match_array([DummiesIndex::Fizz, DummiesIndex::Buzz])
78
+ expect(deletes.keys).to match_array([DummiesIndex::Fizz, Dummies2Index::Buzz])
77
79
  expect(deletes.values.flatten).to match_array([1, 2, 1, 2, 3])
78
80
  end
79
81
  end
@@ -113,8 +115,8 @@ describe :search_index_receiver do
113
115
  context 'updated_indexes' do
114
116
  specify 'provides a list of indices updated' do
115
117
  receiver.catch search_request(2, verb: :delete), DummiesIndex::Fizz
116
- receiver.catch search_request(3, verb: :delete), DummiesIndex::Buzz
117
- expect(receiver.updated_indexes).to match_array([DummiesIndex::Fizz, DummiesIndex::Buzz])
118
+ receiver.catch search_request(3, verb: :delete), Dummies2Index::Buzz
119
+ expect(receiver.updated_indexes).to match_array([DummiesIndex::Fizz, Dummies2Index::Buzz])
118
120
  end
119
121
  end
120
122
  end
@@ -0,0 +1,85 @@
1
+ require 'spec_helper'
2
+ require 'chewy/multi_search'
3
+
4
+ describe Chewy::MultiSearch do
5
+ before { Chewy.massacre }
6
+
7
+ before do
8
+ stub_model(:city)
9
+ stub_model(:country)
10
+
11
+ stub_index(:cities) do
12
+ def self.aggregate_by_country
13
+ aggs(country: {terms: {field: :country_id}})
14
+ end
15
+
16
+ define_type City do
17
+ field :name, type: 'keyword'
18
+ field :country_id, type: 'keyword'
19
+ end
20
+ end
21
+ end
22
+
23
+ let(:places_query) { CitiesIndex.all }
24
+
25
+ describe '#queries' do
26
+ specify 'returns the queries that are a part of the multi search' do
27
+ multi_search = described_class.new([places_query])
28
+ expect(multi_search.queries).to contain_exactly(places_query)
29
+ end
30
+ end
31
+
32
+ describe '#add_query' do
33
+ specify 'adds a query to the multi search' do
34
+ multi_search = described_class.new([])
35
+ expect do
36
+ multi_search.add_query(places_query)
37
+ end.to change {
38
+ multi_search.queries
39
+ }.from([]).to([places_query])
40
+ end
41
+ end
42
+
43
+ context 'when given two queries' do
44
+ let(:queries) { [aggregates, results] }
45
+ let(:aggregates) { CitiesIndex.aggregate_by_country.limit(0) }
46
+ let(:results) { CitiesIndex.limit(10) }
47
+ let(:multi_search) { described_class.new(queries) }
48
+ let(:cities) { Array.new(3) { |i| City.create! name: "Name#{i + 2}", country_id: i + 1 } }
49
+ before { CitiesIndex.import! city: cities }
50
+
51
+ describe '#perform' do
52
+ specify 'performs each query' do
53
+ expect { multi_search.perform }
54
+ .to change(aggregates, :performed?).from(false).to(true)
55
+ .and change(results, :performed?).from(false).to(true)
56
+ end
57
+
58
+ specify 'issues a single request using the msearch endpoint', :aggregate_failures do
59
+ expect(Chewy.client).to receive(:msearch).once.and_return('responses' => [])
60
+ expect(Chewy.client).to_not receive(:search)
61
+ multi_search.perform
62
+ end
63
+ end
64
+
65
+ describe '#responses' do
66
+ subject(:responses) { multi_search.responses }
67
+
68
+ context 'on a previously performed multi search' do
69
+ before { multi_search.perform }
70
+
71
+ it 'does not perform the query again' do
72
+ expect(Chewy.client).to_not receive(:msearch)
73
+ multi_search.responses
74
+ end
75
+ end
76
+
77
+ specify 'returns the results of each query', :aggregate_failures do
78
+ is_expected.to have(2).responses
79
+ expect(responses[0]).to be_a(Chewy::Search::Response)
80
+ expect(responses[1]).to be_a(Chewy::Search::Response)
81
+ expect(responses[1].wrappers).to all(be_a CitiesIndex::City)
82
+ end
83
+ end
84
+ end
85
+ end
@@ -7,16 +7,18 @@ describe Chewy::RakeHelper, :orm do
7
7
  stub_model(:city)
8
8
  stub_model(:country)
9
9
 
10
- stub_index(:places) do
10
+ stub_index(:cities) do
11
11
  define_type City do
12
12
  field :name
13
13
  field :updated_at, type: 'date'
14
14
  end
15
+ end
16
+ stub_index(:countries) do
15
17
  define_type Country
16
18
  end
17
19
  stub_index(:users)
18
20
 
19
- allow(described_class).to receive(:all_indexes) { [PlacesIndex, UsersIndex] }
21
+ allow(described_class).to receive(:all_indexes) { [CitiesIndex, CountriesIndex, UsersIndex] }
20
22
  end
21
23
 
22
24
  let!(:cities) { Array.new(3) { |i| City.create!(name: "Name#{i + 1}") } }
@@ -24,7 +26,7 @@ describe Chewy::RakeHelper, :orm do
24
26
  let(:journal) do
25
27
  Chewy::Stash::Journal.import([
26
28
  {
27
- index_name: 'places',
29
+ index_name: 'cities',
28
30
  type_name: 'city',
29
31
  action: 'index',
30
32
  references: cities.first(2).map(&:id).map(&:to_s)
@@ -32,7 +34,7 @@ describe Chewy::RakeHelper, :orm do
32
34
  created_at: 2.minutes.since
33
35
  },
34
36
  {
35
- index_name: 'places',
37
+ index_name: 'countries',
36
38
  type_name: 'country',
37
39
  action: 'index',
38
40
  references: [Base64.encode64(countries.first.id.to_s.to_json)],
@@ -47,14 +49,17 @@ describe Chewy::RakeHelper, :orm do
47
49
  specify do
48
50
  output = StringIO.new
49
51
  expect { described_class.reset(output: output) }
50
- .to update_index(PlacesIndex::City)
52
+ .to update_index(CitiesIndex)
51
53
  expect(output.string).to match(Regexp.new(<<-OUTPUT, Regexp::MULTILINE))
52
- \\AResetting PlacesIndex
53
- Imported PlacesIndex::City in \\d+s, stats: index 3
54
- Imported PlacesIndex::Country in \\d+s, stats: index 2
55
- Applying journal to \\[PlacesIndex::City, PlacesIndex::Country\\], 3 entries, stage 1
56
- Imported PlacesIndex::City in \\d+s, stats: index 2
57
- Imported PlacesIndex::Country in \\d+s, stats: index 1
54
+ \\AResetting CitiesIndex
55
+ Imported CitiesIndex::City in \\d+s, stats: index 3
56
+ Applying journal to \\[CitiesIndex::City\\], 2 entries, stage 1
57
+ Imported CitiesIndex::City in \\d+s, stats: index 2
58
+ Imported Chewy::Stash::Specification::Specification in \\d+s, stats: index 1
59
+ Resetting CountriesIndex
60
+ Imported CountriesIndex::Country in \\d+s, stats: index 2
61
+ Applying journal to \\[CountriesIndex::Country\\], 1 entries, stage 1
62
+ Imported CountriesIndex::Country in \\d+s, stats: index 1
58
63
  Imported Chewy::Stash::Specification::Specification in \\d+s, stats: index 1
59
64
  Resetting UsersIndex
60
65
  Imported Chewy::Stash::Specification::Specification in \\d+s, stats: index 1
@@ -64,15 +69,13 @@ Total: \\d+s\\Z
64
69
 
65
70
  specify do
66
71
  output = StringIO.new
67
- expect { described_class.reset(only: 'places', output: output) }
68
- .to update_index(PlacesIndex::City)
72
+ expect { described_class.reset(only: 'cities', output: output) }
73
+ .to update_index(CitiesIndex)
69
74
  expect(output.string).to match(Regexp.new(<<-OUTPUT, Regexp::MULTILINE))
70
- \\AResetting PlacesIndex
71
- Imported PlacesIndex::City in \\d+s, stats: index 3
72
- Imported PlacesIndex::Country in \\d+s, stats: index 2
73
- Applying journal to \\[PlacesIndex::City, PlacesIndex::Country\\], 3 entries, stage 1
74
- Imported PlacesIndex::City in \\d+s, stats: index 2
75
- Imported PlacesIndex::Country in \\d+s, stats: index 1
75
+ \\AResetting CitiesIndex
76
+ Imported CitiesIndex::City in \\d+s, stats: index 3
77
+ Applying journal to \\[CitiesIndex::City\\], 2 entries, stage 1
78
+ Imported CitiesIndex::City in \\d+s, stats: index 2
76
79
  Imported Chewy::Stash::Specification::Specification in \\d+s, stats: index 1
77
80
  Total: \\d+s\\Z
78
81
  OUTPUT
@@ -80,8 +83,8 @@ Total: \\d+s\\Z
80
83
 
81
84
  specify do
82
85
  output = StringIO.new
83
- expect { described_class.reset(except: PlacesIndex, output: output) }
84
- .not_to update_index(PlacesIndex::City)
86
+ expect { described_class.reset(except: [CitiesIndex, CountriesIndex], output: output) }
87
+ .not_to update_index(CitiesIndex)
85
88
  expect(output.string).to match(Regexp.new(<<-OUTPUT, Regexp::MULTILINE))
86
89
  \\AResetting UsersIndex
87
90
  Imported Chewy::Stash::Specification::Specification in \\d+s, stats: index 1
@@ -94,11 +97,13 @@ Total: \\d+s\\Z
94
97
  specify do
95
98
  output = StringIO.new
96
99
  expect { described_class.upgrade(output: output) }
97
- .to update_index(PlacesIndex::City)
100
+ .to update_index(CitiesIndex)
98
101
  expect(output.string).to match(Regexp.new(<<-OUTPUT, Regexp::MULTILINE))
99
- \\AResetting PlacesIndex
100
- Imported PlacesIndex::City in \\d+s, stats: index 3
101
- Imported PlacesIndex::Country in \\d+s, stats: index 2
102
+ \\AResetting CitiesIndex
103
+ Imported CitiesIndex::City in \\d+s, stats: index 3
104
+ Imported Chewy::Stash::Specification::Specification in \\d+s, stats: index 1
105
+ Resetting CountriesIndex
106
+ Imported CountriesIndex::Country in \\d+s, stats: index 2
102
107
  Imported Chewy::Stash::Specification::Specification in \\d+s, stats: index 1
103
108
  Resetting UsersIndex
104
109
  Imported Chewy::Stash::Specification::Specification in \\d+s, stats: index 1
@@ -107,14 +112,18 @@ Total: \\d+s\\Z
107
112
  end
108
113
 
109
114
  context do
110
- before { PlacesIndex.reset! }
115
+ before do
116
+ CitiesIndex.reset!
117
+ CountriesIndex.reset!
118
+ end
111
119
 
112
120
  specify do
113
121
  output = StringIO.new
114
122
  expect { described_class.upgrade(output: output) }
115
- .not_to update_index(PlacesIndex::City)
123
+ .not_to update_index(CitiesIndex)
116
124
  expect(output.string).to match(Regexp.new(<<-OUTPUT, Regexp::MULTILINE))
117
- \\ASkipping PlacesIndex, the specification didn't change
125
+ \\ASkipping CitiesIndex, the specification didn't change
126
+ Skipping CountriesIndex, the specification didn't change
118
127
  Resetting UsersIndex
119
128
  Imported Chewy::Stash::Specification::Specification in \\d+s, stats: index 1
120
129
  Total: \\d+s\\Z
@@ -123,8 +132,8 @@ Total: \\d+s\\Z
123
132
 
124
133
  specify do
125
134
  output = StringIO.new
126
- expect { described_class.upgrade(except: PlacesIndex, output: output) }
127
- .not_to update_index(PlacesIndex::City)
135
+ expect { described_class.upgrade(except: [CitiesIndex, CountriesIndex], output: output) }
136
+ .not_to update_index(CitiesIndex)
128
137
  expect(output.string).to match(Regexp.new(<<-OUTPUT, Regexp::MULTILINE))
129
138
  \\AResetting UsersIndex
130
139
  Imported Chewy::Stash::Specification::Specification in \\d+s, stats: index 1
@@ -137,8 +146,8 @@ Total: \\d+s\\Z
137
146
 
138
147
  specify do
139
148
  output = StringIO.new
140
- expect { described_class.upgrade(except: ['places'], output: output) }
141
- .not_to update_index(PlacesIndex::City)
149
+ expect { described_class.upgrade(except: %w[cities countries], output: output) }
150
+ .not_to update_index(CitiesIndex)
142
151
  expect(output.string).to match(Regexp.new(<<-OUTPUT, Regexp::MULTILINE))
143
152
  \\ANo index specification was changed
144
153
  Total: \\d+s\\Z
@@ -152,45 +161,51 @@ Total: \\d+s\\Z
152
161
  specify do
153
162
  output = StringIO.new
154
163
  expect { described_class.update(output: output) }
155
- .not_to update_index(PlacesIndex::City)
164
+ .not_to update_index(CitiesIndex)
156
165
  expect(output.string).to match(Regexp.new(<<-OUTPUT, Regexp::MULTILINE))
157
- \\ASkipping PlacesIndex, it does not exists \\(use rake chewy:reset\\[places\\] to create and update it\\)
166
+ \\ASkipping CitiesIndex, it does not exists \\(use rake chewy:reset\\[cities\\] to create and update it\\)
167
+ Skipping CountriesIndex, it does not exists \\(use rake chewy:reset\\[countries\\] to create and update it\\)
168
+ Total: \\d+s\\Z
158
169
  OUTPUT
159
170
  end
160
171
 
161
172
  context do
162
- before { PlacesIndex.reset! }
173
+ before do
174
+ CitiesIndex.reset!
175
+ CountriesIndex.reset!
176
+ end
163
177
 
164
178
  specify do
165
179
  output = StringIO.new
166
180
  expect { described_class.update(output: output) }
167
- .to update_index(PlacesIndex::City)
181
+ .to update_index(CitiesIndex)
168
182
  expect(output.string).to match(Regexp.new(<<-OUTPUT, Regexp::MULTILINE))
169
- \\AUpdating PlacesIndex
170
- Imported PlacesIndex::City in \\d+s, stats: index 3
171
- Imported PlacesIndex::Country in \\d+s, stats: index 2
183
+ \\AUpdating CitiesIndex
184
+ Imported CitiesIndex::City in \\d+s, stats: index 3
185
+ Updating CountriesIndex
186
+ Imported CountriesIndex::Country in \\d+s, stats: index 2
172
187
  Total: \\d+s\\Z
173
188
  OUTPUT
174
189
  end
175
190
 
176
191
  specify do
177
192
  output = StringIO.new
178
- expect { described_class.update(only: 'places#country', output: output) }
179
- .not_to update_index(PlacesIndex::City)
193
+ expect { described_class.update(only: 'countries', output: output) }
194
+ .not_to update_index(CitiesIndex)
180
195
  expect(output.string).to match(Regexp.new(<<-OUTPUT, Regexp::MULTILINE))
181
- \\AUpdating PlacesIndex
182
- Imported PlacesIndex::Country in \\d+s, stats: index 2
196
+ \\AUpdating CountriesIndex
197
+ Imported CountriesIndex::Country in \\d+s, stats: index 2
183
198
  Total: \\d+s\\Z
184
199
  OUTPUT
185
200
  end
186
201
 
187
202
  specify do
188
203
  output = StringIO.new
189
- expect { described_class.update(except: PlacesIndex::Country, output: output) }
190
- .to update_index(PlacesIndex::City)
204
+ expect { described_class.update(except: CountriesIndex, output: output) }
205
+ .to update_index(CitiesIndex)
191
206
  expect(output.string).to match(Regexp.new(<<-OUTPUT, Regexp::MULTILINE))
192
- \\AUpdating PlacesIndex
193
- Imported PlacesIndex::City in \\d+s, stats: index 3
207
+ \\AUpdating CitiesIndex
208
+ Imported CitiesIndex::City in \\d+s, stats: index 3
194
209
  Total: \\d+s\\Z
195
210
  OUTPUT
196
211
  end
@@ -201,15 +216,15 @@ Total: \\d+s\\Z
201
216
  specify do
202
217
  output = StringIO.new
203
218
  expect { described_class.sync(output: output) }
204
- .to update_index(PlacesIndex::City)
219
+ .to update_index(CitiesIndex)
205
220
  expect(output.string).to match(Regexp.new(<<-OUTPUT, Regexp::MULTILINE))
206
- \\ASynchronizing PlacesIndex::City
207
- Imported PlacesIndex::City in \\d+s, stats: index 3
221
+ \\ASynchronizing CitiesIndex::City
222
+ Imported CitiesIndex::City in \\d+s, stats: index 3
208
223
  Missing documents: \\[[^\\]]+\\]
209
224
  Took \\d+s
210
- Synchronizing PlacesIndex::Country
211
- PlacesIndex::Country doesn't support outdated synchronization
212
- Imported PlacesIndex::Country in \\d+s, stats: index 2
225
+ Synchronizing CountriesIndex::Country
226
+ CountriesIndex::Country doesn't support outdated synchronization
227
+ Imported CountriesIndex::Country in \\d+s, stats: index 2
213
228
  Missing documents: \\[[^\\]]+\\]
214
229
  Took \\d+s
215
230
  Total: \\d+s\\Z
@@ -218,8 +233,8 @@ Total: \\d+s\\Z
218
233
 
219
234
  context do
220
235
  before do
221
- PlacesIndex::City.import(cities.first(2))
222
- PlacesIndex::Country.import
236
+ CitiesIndex.import(cities.first(2))
237
+ CountriesIndex.import
223
238
 
224
239
  sleep(1) if ActiveSupport::VERSION::STRING < '4.1.0'
225
240
  cities.first.update(name: 'Name5')
@@ -228,16 +243,16 @@ Total: \\d+s\\Z
228
243
  specify do
229
244
  output = StringIO.new
230
245
  expect { described_class.sync(output: output) }
231
- .to update_index(PlacesIndex::City)
246
+ .to update_index(CitiesIndex)
232
247
  expect(output.string).to match(Regexp.new(<<-OUTPUT, Regexp::MULTILINE))
233
- \\ASynchronizing PlacesIndex::City
234
- Imported PlacesIndex::City in \\d+s, stats: index 2
248
+ \\ASynchronizing CitiesIndex::City
249
+ Imported CitiesIndex::City in \\d+s, stats: index 2
235
250
  Missing documents: \\["#{cities.last.id}"\\]
236
251
  Outdated documents: \\["#{cities.first.id}"\\]
237
252
  Took \\d+s
238
- Synchronizing PlacesIndex::Country
239
- PlacesIndex::Country doesn't support outdated synchronization
240
- Skipping PlacesIndex::Country, up to date
253
+ Synchronizing CountriesIndex::Country
254
+ CountriesIndex::Country doesn't support outdated synchronization
255
+ Skipping CountriesIndex::Country, up to date
241
256
  Took \\d+s
242
257
  Total: \\d+s\\Z
243
258
  OUTPUT
@@ -245,11 +260,11 @@ Total: \\d+s\\Z
245
260
 
246
261
  specify do
247
262
  output = StringIO.new
248
- expect { described_class.sync(only: PlacesIndex::City, output: output) }
249
- .to update_index(PlacesIndex::City)
263
+ expect { described_class.sync(only: CitiesIndex, output: output) }
264
+ .to update_index(CitiesIndex)
250
265
  expect(output.string).to match(Regexp.new(<<-OUTPUT, Regexp::MULTILINE))
251
- \\ASynchronizing PlacesIndex::City
252
- Imported PlacesIndex::City in \\d+s, stats: index 2
266
+ \\ASynchronizing CitiesIndex::City
267
+ Imported CitiesIndex::City in \\d+s, stats: index 2
253
268
  Missing documents: \\["#{cities.last.id}"\\]
254
269
  Outdated documents: \\["#{cities.first.id}"\\]
255
270
  Took \\d+s
@@ -259,12 +274,12 @@ Total: \\d+s\\Z
259
274
 
260
275
  specify do
261
276
  output = StringIO.new
262
- expect { described_class.sync(except: ['places#city'], output: output) }
263
- .not_to update_index(PlacesIndex::City)
277
+ expect { described_class.sync(except: ['cities'], output: output) }
278
+ .not_to update_index(CitiesIndex)
264
279
  expect(output.string).to match(Regexp.new(<<-OUTPUT, Regexp::MULTILINE))
265
- \\ASynchronizing PlacesIndex::Country
266
- PlacesIndex::Country doesn't support outdated synchronization
267
- Skipping PlacesIndex::Country, up to date
280
+ \\ASynchronizing CountriesIndex::Country
281
+ CountriesIndex::Country doesn't support outdated synchronization
282
+ Skipping CountriesIndex::Country, up to date
268
283
  Took \\d+s
269
284
  Total: \\d+s\\Z
270
285
  OUTPUT
@@ -290,12 +305,12 @@ Total: \\d+s\\Z
290
305
  specify do
291
306
  output = StringIO.new
292
307
  expect { described_class.journal_apply(time: Time.now, output: output) }
293
- .to update_index(PlacesIndex::City)
308
+ .to update_index(CitiesIndex)
294
309
  expect(output.string).to match(Regexp.new(<<-OUTPUT, Regexp::MULTILINE))
295
310
  \\AApplying journal entries created after [+-:\\d\\s]+
296
- Applying journal to \\[PlacesIndex::City, PlacesIndex::Country\\], 3 entries, stage 1
297
- Imported PlacesIndex::City in \\d+s, stats: index 2
298
- Imported PlacesIndex::Country in \\d+s, stats: index 1
311
+ Applying journal to \\[CitiesIndex::City, CountriesIndex::Country\\], 3 entries, stage 1
312
+ Imported CitiesIndex::City in \\d+s, stats: index 2
313
+ Imported CountriesIndex::Country in \\d+s, stats: index 1
299
314
  Total: \\d+s\\Z
300
315
  OUTPUT
301
316
  end
@@ -303,35 +318,35 @@ Total: \\d+s\\Z
303
318
  specify do
304
319
  output = StringIO.new
305
320
  expect { described_class.journal_apply(time: 3.minutes.since, output: output) }
306
- .not_to update_index(PlacesIndex::City)
321
+ .not_to update_index(CitiesIndex)
307
322
  expect(output.string).to match(Regexp.new(<<-OUTPUT, Regexp::MULTILINE))
308
323
  \\AApplying journal entries created after [+-:\\d\\s]+
309
- Applying journal to \\[PlacesIndex::Country\\], 1 entries, stage 1
310
- Imported PlacesIndex::Country in \\d+s, stats: index 1
324
+ Applying journal to \\[CountriesIndex::Country\\], 1 entries, stage 1
325
+ Imported CountriesIndex::Country in \\d+s, stats: index 1
311
326
  Total: \\d+s\\Z
312
327
  OUTPUT
313
328
  end
314
329
 
315
330
  specify do
316
331
  output = StringIO.new
317
- expect { described_class.journal_apply(time: Time.now, only: PlacesIndex::City, output: output) }
318
- .to update_index(PlacesIndex::City)
332
+ expect { described_class.journal_apply(time: Time.now, only: CitiesIndex, output: output) }
333
+ .to update_index(CitiesIndex)
319
334
  expect(output.string).to match(Regexp.new(<<-OUTPUT, Regexp::MULTILINE))
320
335
  \\AApplying journal entries created after [+-:\\d\\s]+
321
- Applying journal to \\[PlacesIndex::City\\], 2 entries, stage 1
322
- Imported PlacesIndex::City in \\d+s, stats: index 2
336
+ Applying journal to \\[CitiesIndex::City\\], 2 entries, stage 1
337
+ Imported CitiesIndex::City in \\d+s, stats: index 2
323
338
  Total: \\d+s\\Z
324
339
  OUTPUT
325
340
  end
326
341
 
327
342
  specify do
328
343
  output = StringIO.new
329
- expect { described_class.journal_apply(time: Time.now, except: PlacesIndex::City, output: output) }
330
- .not_to update_index(PlacesIndex::City)
344
+ expect { described_class.journal_apply(time: Time.now, except: CitiesIndex, output: output) }
345
+ .not_to update_index(CitiesIndex)
331
346
  expect(output.string).to match(Regexp.new(<<-OUTPUT, Regexp::MULTILINE))
332
347
  \\AApplying journal entries created after [+-:\\d\\s]+
333
- Applying journal to \\[PlacesIndex::Country\\], 1 entries, stage 1
334
- Imported PlacesIndex::Country in \\d+s, stats: index 1
348
+ Applying journal to \\[CountriesIndex::Country\\], 1 entries, stage 1
349
+ Imported CountriesIndex::Country in \\d+s, stats: index 1
335
350
  Total: \\d+s\\Z
336
351
  OUTPUT
337
352
  end
@@ -362,7 +377,7 @@ Total: \\d+s\\Z
362
377
 
363
378
  specify do
364
379
  output = StringIO.new
365
- described_class.journal_clean(only: PlacesIndex::City, output: output)
380
+ described_class.journal_clean(only: CitiesIndex, output: output)
366
381
  expect(output.string).to match(Regexp.new(<<-OUTPUT, Regexp::MULTILINE))
367
382
  \\ACleaned up 1 journal entries
368
383
  Total: \\d+s\\Z
@@ -371,7 +386,7 @@ Total: \\d+s\\Z
371
386
 
372
387
  specify do
373
388
  output = StringIO.new
374
- described_class.journal_clean(except: PlacesIndex::City, output: output)
389
+ described_class.journal_clean(except: CitiesIndex, output: output)
375
390
  expect(output.string).to match(Regexp.new(<<-OUTPUT, Regexp::MULTILINE))
376
391
  \\ACleaned up 1 journal entries
377
392
  Total: \\d+s\\Z