chewy 6.0.0 → 7.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -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
@@ -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 >= '5.6' }
7
- specify { expect(described_class.version).to be < '7.0' }
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: {index: ['products'], type: %w[product], body: {query: {match: {name: 'name3'}}}},
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: {index: %w[cities countries], type: %w[city country], body: {sort: ['rating']}, size: 3, scroll: '1m'},
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
- raise "Expected no DB queries, but the following ones were made: #{queries.join(', ')}" if queries.present?
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: 6.0.0
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-11 00:00:00.000000000 Z
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