chewy 6.0.0 → 7.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.circleci/config.yml +9 -9
- 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/CHANGELOG.md +120 -108
- data/CODE_OF_CONDUCT.md +14 -0
- data/CONTRIBUTING.md +63 -0
- data/README.md +8 -6
- data/lib/chewy/index/actions.rb +1 -1
- data/lib/chewy/index/aliases.rb +16 -5
- data/lib/chewy/search/request.rb +1 -0
- data/lib/chewy/stash.rb +1 -1
- data/lib/chewy/type/import.rb +10 -1
- data/lib/chewy/version.rb +1 -1
- data/migration_guide.md +24 -8
- data/spec/chewy/index/actions_spec.rb +94 -31
- data/spec/chewy/index/aliases_spec.rb +3 -3
- data/spec/chewy/runtime_spec.rb +2 -2
- data/spec/chewy/search/request_spec.rb +3 -1
- data/spec/chewy/search/scrolling_spec.rb +3 -2
- data/spec/chewy/type/import_spec.rb +9 -0
- data/spec/support/active_record.rb +3 -2
- metadata +7 -2
@@ -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
|
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
|
@@ -420,10 +420,12 @@ describe Chewy::Search::Request do
|
|
420
420
|
outer_payload = payload
|
421
421
|
end
|
422
422
|
subject.query(match: {name: 'name3'}).to_a
|
423
|
+
request = {index: ['products'], type: %w[product], body: {query: {match: {name: 'name3'}}}}
|
424
|
+
request[:rest_total_hits_as_int] = true if Chewy::Runtime.version >= '7.0.0'
|
423
425
|
expect(outer_payload).to eq(
|
424
426
|
index: ProductsIndex,
|
425
427
|
indexes: [ProductsIndex],
|
426
|
-
request:
|
428
|
+
request: request,
|
427
429
|
type: ProductsIndex::Product,
|
428
430
|
types: [ProductsIndex::Product]
|
429
431
|
)
|
@@ -119,12 +119,13 @@ describe Chewy::Search::Scrolling, :orm do
|
|
119
119
|
outer_payload << payload
|
120
120
|
end
|
121
121
|
request.scroll_batches(batch_size: 3).to_a
|
122
|
-
|
122
|
+
request = {index: %w[cities countries], type: %w[city country], body: {sort: ['rating']}, size: 3, scroll: '1m'}
|
123
|
+
request[:rest_total_hits_as_int] = true if Chewy::Runtime.version >= '7.0.0'
|
123
124
|
expect(outer_payload).to match_array([
|
124
125
|
hash_including(
|
125
126
|
index: [CitiesIndex, CountriesIndex],
|
126
127
|
indexes: [CitiesIndex, CountriesIndex],
|
127
|
-
request:
|
128
|
+
request: request,
|
128
129
|
type: [CitiesIndex::City, CountriesIndex::Country],
|
129
130
|
types: [CitiesIndex::City, CountriesIndex::Country]
|
130
131
|
),
|
@@ -158,6 +158,15 @@ describe Chewy::Type::Import do
|
|
158
158
|
specify do
|
159
159
|
expect { import City.where(id: dummy_cities.first.id) }.to update_index(CitiesIndex::City).and_reindex(dummy_cities.first).only
|
160
160
|
end
|
161
|
+
|
162
|
+
specify do
|
163
|
+
allow(CitiesIndex::City).to receive(:import_linear).and_return(double(present?: false))
|
164
|
+
allow(CitiesIndex::City).to receive(:import_parallel).and_return(double(present?: false))
|
165
|
+
|
166
|
+
expects_no_query(except: /SELECT\s+1\s+AS\s+one\s+FROM/) do
|
167
|
+
import City.where(id: dummy_cities.first.id)
|
168
|
+
end
|
169
|
+
end
|
161
170
|
end
|
162
171
|
end
|
163
172
|
|
@@ -39,14 +39,15 @@ module ActiveRecordClassHelpers
|
|
39
39
|
raise 'Expected some db queries, but none were made' unless have_queries
|
40
40
|
end
|
41
41
|
|
42
|
-
def expects_no_query(&block)
|
42
|
+
def expects_no_query(except: nil, &block)
|
43
43
|
queries = []
|
44
44
|
ActiveSupport::Notifications.subscribed(
|
45
45
|
->(*args) { queries << args[4][:sql] },
|
46
46
|
'sql.active_record',
|
47
47
|
&block
|
48
48
|
)
|
49
|
-
|
49
|
+
ofending_queries = except ? queries.find_all { |query| !query.match(except) } : queries
|
50
|
+
raise "Expected no DB queries, but the following ones were made: #{ofending_queries.join(', ')}" if ofending_queries.present?
|
50
51
|
end
|
51
52
|
|
52
53
|
def stub_model(name, superclass = nil, &block)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: chewy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 7.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Toptal, LLC
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2021-02-
|
12
|
+
date: 2021-02-22 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: appraisal
|
@@ -245,6 +245,9 @@ extensions: []
|
|
245
245
|
extra_rdoc_files: []
|
246
246
|
files:
|
247
247
|
- ".circleci/config.yml"
|
248
|
+
- ".github/ISSUE_TEMPLATE/bug_report.md"
|
249
|
+
- ".github/ISSUE_TEMPLATE/feature_request.md"
|
250
|
+
- ".github/PULL_REQUEST_TEMPLATE.md"
|
248
251
|
- ".gitignore"
|
249
252
|
- ".rspec"
|
250
253
|
- ".rubocop.yml"
|
@@ -252,6 +255,8 @@ files:
|
|
252
255
|
- ".yardopts"
|
253
256
|
- Appraisals
|
254
257
|
- CHANGELOG.md
|
258
|
+
- CODE_OF_CONDUCT.md
|
259
|
+
- CONTRIBUTING.md
|
255
260
|
- Gemfile
|
256
261
|
- Guardfile
|
257
262
|
- LICENSE.txt
|