chewy 5.1.0 → 5.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (55) hide show
  1. checksums.yaml +4 -4
  2. data/.circleci/config.yml +214 -0
  3. data/CHANGELOG.md +26 -0
  4. data/Gemfile +2 -0
  5. data/LICENSE.txt +1 -1
  6. data/README.md +60 -34
  7. data/chewy.gemspec +4 -4
  8. data/gemfiles/rails.5.2.activerecord.gemfile +1 -0
  9. data/gemfiles/{rails.5.0.activerecord.gemfile → rails.5.2.mongoid.6.4.gemfile} +4 -3
  10. data/gemfiles/{rails.5.0.mongoid.6.1.gemfile → rails.6.0.activerecord.gemfile} +4 -3
  11. data/gemfiles/{rails.5.1.activerecord.gemfile → rails.6.1.activerecord.gemfile} +6 -3
  12. data/gemfiles/ruby3.gemfile +10 -0
  13. data/lib/chewy.rb +1 -1
  14. data/lib/chewy/backports/duplicable.rb +1 -1
  15. data/lib/chewy/fields/base.rb +1 -1
  16. data/lib/chewy/fields/root.rb +2 -2
  17. data/lib/chewy/index/actions.rb +9 -3
  18. data/lib/chewy/query/loading.rb +1 -1
  19. data/lib/chewy/query/nodes/field.rb +1 -1
  20. data/lib/chewy/search/loader.rb +1 -1
  21. data/lib/chewy/search/parameters.rb +2 -1
  22. data/lib/chewy/search/request.rb +1 -0
  23. data/lib/chewy/strategy/active_job.rb +1 -1
  24. data/lib/chewy/strategy/sidekiq.rb +1 -1
  25. data/lib/chewy/type/adapter/active_record.rb +1 -1
  26. data/lib/chewy/type/adapter/mongoid.rb +1 -1
  27. data/lib/chewy/type/adapter/orm.rb +1 -1
  28. data/lib/chewy/type/adapter/sequel.rb +1 -1
  29. data/lib/chewy/type/import.rb +3 -3
  30. data/lib/chewy/type/import/routine.rb +1 -1
  31. data/lib/chewy/type/mapping.rb +4 -4
  32. data/lib/chewy/type/observe.rb +3 -3
  33. data/lib/chewy/type/witchcraft.rb +1 -1
  34. data/lib/chewy/version.rb +1 -1
  35. data/spec/chewy/config_spec.rb +1 -1
  36. data/spec/chewy/fields/base_spec.rb +11 -9
  37. data/spec/chewy/index/actions_spec.rb +2 -2
  38. data/spec/chewy/journal_spec.rb +1 -1
  39. data/spec/chewy/search/parameters_spec.rb +4 -2
  40. data/spec/chewy/search/response_spec.rb +8 -2
  41. data/spec/chewy/search_spec.rb +2 -2
  42. data/spec/chewy/strategy/active_job_spec.rb +15 -2
  43. data/spec/chewy/strategy/shoryuken_spec.rb +6 -2
  44. data/spec/chewy/strategy/sidekiq_spec.rb +6 -2
  45. data/spec/chewy/type/adapter/active_record_spec.rb +3 -3
  46. data/spec/chewy/type/import/bulk_builder_spec.rb +1 -1
  47. data/spec/chewy/type/observe_spec.rb +4 -4
  48. data/spec/spec_helper.rb +4 -1
  49. metadata +17 -19
  50. data/.travis.yml +0 -45
  51. data/gemfiles/rails.4.0.activerecord.gemfile +0 -15
  52. data/gemfiles/rails.4.1.activerecord.gemfile +0 -15
  53. data/gemfiles/rails.4.2.activerecord.gemfile +0 -16
  54. data/gemfiles/rails.4.2.mongoid.5.2.gemfile +0 -16
  55. data/gemfiles/rails.5.1.mongoid.6.3.gemfile +0 -16
@@ -72,7 +72,10 @@ describe Chewy::Search::Response, :orm do
72
72
  Chewy::Search::Request.new(PlacesIndex)
73
73
  .query(script: {script: {inline: 'sleep(100); true', lang: 'groovy'}})
74
74
  end
75
- specify { expect(subject.took).to be > 100 }
75
+ specify do
76
+ pending
77
+ expect(subject.took).to be > 100
78
+ end
76
79
  end
77
80
  end
78
81
 
@@ -84,7 +87,10 @@ describe Chewy::Search::Response, :orm do
84
87
  Chewy::Search::Request.new(PlacesIndex)
85
88
  .query(script: {script: {inline: 'sleep(100); true', lang: 'groovy'}}).timeout('10ms')
86
89
  end
87
- specify { expect(subject.timed_out?).to eq(true) }
90
+ specify do
91
+ pending
92
+ expect(subject.timed_out?).to eq(true)
93
+ end
88
94
  end
89
95
  end
90
96
 
@@ -71,12 +71,12 @@ describe Chewy::Search do
71
71
  filter { match name: "Name#{index}" }
72
72
  end
73
73
 
74
- field :name, KEYWORD_FIELD
74
+ field :name, **KEYWORD_FIELD
75
75
  field :rating, type: :integer
76
76
  end
77
77
 
78
78
  define_type Country do
79
- field :name, KEYWORD_FIELD
79
+ field :name, **KEYWORD_FIELD
80
80
  field :rating, type: :integer
81
81
  end
82
82
  end
@@ -2,7 +2,12 @@ require 'spec_helper'
2
2
 
3
3
  if defined?(::ActiveJob)
4
4
  describe Chewy::Strategy::ActiveJob do
5
- around { |example| Chewy.strategy(:bypass) { example.run } }
5
+ around do |example|
6
+ active_job_settings = Chewy.settings[:active_job]
7
+ Chewy.settings[:active_job] = {queue: 'low'}
8
+ Chewy.strategy(:bypass) { example.run }
9
+ Chewy.settings[:active_job] = active_job_settings
10
+ end
6
11
  before(:all) do
7
12
  ::ActiveJob::Base.logger = Chewy.logger
8
13
  end
@@ -36,7 +41,15 @@ if defined?(::ActiveJob)
36
41
  end
37
42
  enqueued_job = ::ActiveJob::Base.queue_adapter.enqueued_jobs.first
38
43
  expect(enqueued_job[:job]).to eq(Chewy::Strategy::ActiveJob::Worker)
39
- expect(enqueued_job[:queue]).to eq('chewy')
44
+ expect(enqueued_job[:queue]).to eq('low')
45
+ end
46
+
47
+ specify do
48
+ Chewy.strategy(:active_job) do
49
+ [city, other_city].map(&:save!)
50
+ end
51
+ enqueued_job = ::ActiveJob::Base.queue_adapter.enqueued_jobs.first
52
+ expect(enqueued_job[:queue]).to eq('low')
40
53
  end
41
54
 
42
55
  specify do
@@ -4,7 +4,12 @@ if defined?(::Shoryuken)
4
4
  require 'aws-sdk-sqs'
5
5
 
6
6
  describe Chewy::Strategy::Shoryuken do
7
- around { |example| Chewy.strategy(:bypass) { example.run } }
7
+ around do |example|
8
+ shoryuken_settings = Chewy.settings[:shoryuken]
9
+ Chewy.settings[:shoryuken] = {queue: 'low'}
10
+ Chewy.strategy(:bypass) { example.run }
11
+ Chewy.settings[:shoryuken] = shoryuken_settings
12
+ end
8
13
  before { ::Shoryuken.groups.clear }
9
14
  before do
10
15
  stub_model(:city) do
@@ -31,7 +36,6 @@ if defined?(::Shoryuken)
31
36
  end
32
37
 
33
38
  specify do
34
- Chewy.settings[:shoryuken] = {queue: 'low'}
35
39
  expect(Chewy::Strategy::Shoryuken::Worker).to receive(:perform_async)
36
40
  .with(hash_including(type: 'CitiesIndex::City', ids: [city.id, other_city.id]), hash_including(queue: 'low'))
37
41
  Chewy.strategy(:shoryuken) do
@@ -4,7 +4,12 @@ if defined?(::Sidekiq)
4
4
  require 'sidekiq/testing'
5
5
 
6
6
  describe Chewy::Strategy::Sidekiq do
7
- around { |example| Chewy.strategy(:bypass) { example.run } }
7
+ around do |example|
8
+ sidekiq_settings = Chewy.settings[:sidekiq]
9
+ Chewy.settings[:sidekiq] = {queue: 'low'}
10
+ Chewy.strategy(:bypass) { example.run }
11
+ Chewy.settings[:sidekiq] = sidekiq_settings
12
+ end
8
13
  before { ::Sidekiq::Worker.clear_all }
9
14
  before do
10
15
  stub_model(:city) do
@@ -25,7 +30,6 @@ if defined?(::Sidekiq)
25
30
  end
26
31
 
27
32
  specify do
28
- Chewy.settings[:sidekiq] = {queue: 'low'}
29
33
  expect(::Sidekiq::Client).to receive(:push).with(hash_including('queue' => 'low')).and_call_original
30
34
  ::Sidekiq::Testing.inline! do
31
35
  expect { [city, other_city].map(&:save!) }
@@ -454,9 +454,9 @@ describe Chewy::Type::Adapter::ActiveRecord, :active_record do
454
454
  specify do
455
455
  expect(subject.import_fields(fields: [:updated_at], typecast: false))
456
456
  .to match([contain_exactly(
457
- [1, match(/#{Time.now.strftime('%Y-%m-%d')}/)],
458
- [2, match(/#{Time.now.strftime('%Y-%m-%d')}/)],
459
- [3, match(/#{Time.now.strftime('%Y-%m-%d')}/)]
457
+ [1, match(/#{Time.now.utc.strftime('%Y-%m-%d')}/)],
458
+ [2, match(/#{Time.now.utc.strftime('%Y-%m-%d')}/)],
459
+ [3, match(/#{Time.now.utc.strftime('%Y-%m-%d')}/)]
460
460
  )])
461
461
  end
462
462
  end
@@ -117,7 +117,7 @@ describe Chewy::Type::Import::BulkBuilder do
117
117
  context 'updating parent' do
118
118
  before do
119
119
  PlacesIndex::City.import(city)
120
- city.update_attributes(country_id: another_country.id)
120
+ city.update(country_id: another_country.id)
121
121
  end
122
122
  let(:index) { [city] }
123
123
 
@@ -75,11 +75,11 @@ describe Chewy::Type::Observe do
75
75
  specify { expect { city.save! }.to update_index('cities#city').and_reindex(city).only }
76
76
  specify { expect { city.save! }.to update_index('countries#country').and_reindex(country1).only }
77
77
 
78
- specify { expect { city.update_attributes!(country: nil) }.to update_index('cities#city').and_reindex(city).only }
79
- specify { expect { city.update_attributes!(country: nil) }.to update_index('countries#country').and_reindex(country1).only }
78
+ specify { expect { city.update!(country: nil) }.to update_index('cities#city').and_reindex(city).only }
79
+ specify { expect { city.update!(country: nil) }.to update_index('countries#country').and_reindex(country1).only }
80
80
 
81
- specify { expect { city.update_attributes!(country: country2) }.to update_index('cities#city').and_reindex(city).only }
82
- specify { expect { city.update_attributes!(country: country2) }.to update_index('countries#country').and_reindex(country1, country2).only }
81
+ specify { expect { city.update!(country: country2) }.to update_index('cities#city').and_reindex(city).only }
82
+ specify { expect { city.update!(country: country2) }.to update_index('countries#country').and_reindex(country1, country2).only }
83
83
  end
84
84
 
85
85
  context do
@@ -21,8 +21,11 @@ require 'support/class_helpers'
21
21
 
22
22
  require 'chewy/rspec'
23
23
 
24
+ host = ENV['ES_HOST'] || 'localhost'
25
+ port = ENV['ES_PORT'] || 9250
26
+
24
27
  Chewy.settings = {
25
- host: 'localhost:9250',
28
+ host: "#{host}:#{port}",
26
29
  wait_for_status: 'green',
27
30
  index: {
28
31
  number_of_shards: 1,
metadata CHANGED
@@ -1,14 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: chewy
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.1.0
4
+ version: 5.2.0
5
5
  platform: ruby
6
6
  authors:
7
+ - Toptal, LLC
7
8
  - pyromaniac
8
- autorequire:
9
+ autorequire:
9
10
  bindir: bin
10
11
  cert_chain: []
11
- date: 2019-09-24 00:00:00.000000000 Z
12
+ date: 2021-01-28 00:00:00.000000000 Z
12
13
  dependencies:
13
14
  - !ruby/object:Gem::Dependency
14
15
  name: appraisal
@@ -84,14 +85,14 @@ dependencies:
84
85
  name: rspec
85
86
  requirement: !ruby/object:Gem::Requirement
86
87
  requirements:
87
- - - "~>"
88
+ - - ">="
88
89
  - !ruby/object:Gem::Version
89
90
  version: 3.7.0
90
91
  type: :development
91
92
  prerelease: false
92
93
  version_requirements: !ruby/object:Gem::Requirement
93
94
  requirements:
94
- - - "~>"
95
+ - - ">="
95
96
  - !ruby/object:Gem::Version
96
97
  version: 3.7.0
97
98
  - !ruby/object:Gem::Dependency
@@ -198,14 +199,14 @@ dependencies:
198
199
  requirements:
199
200
  - - ">="
200
201
  - !ruby/object:Gem::Version
201
- version: '4.0'
202
+ version: '5.2'
202
203
  type: :runtime
203
204
  prerelease: false
204
205
  version_requirements: !ruby/object:Gem::Requirement
205
206
  requirements:
206
207
  - - ">="
207
208
  - !ruby/object:Gem::Version
208
- version: '4.0'
209
+ version: '5.2'
209
210
  - !ruby/object:Gem::Dependency
210
211
  name: elasticsearch
211
212
  requirement: !ruby/object:Gem::Requirement
@@ -237,16 +238,17 @@ dependencies:
237
238
  description: Chewy provides functionality for Elasticsearch index handling, documents
238
239
  import mappings and chainable query DSL
239
240
  email:
241
+ - open-source@toptal.com
240
242
  - kinwizard@gmail.com
241
243
  executables: []
242
244
  extensions: []
243
245
  extra_rdoc_files: []
244
246
  files:
247
+ - ".circleci/config.yml"
245
248
  - ".gitignore"
246
249
  - ".rspec"
247
250
  - ".rubocop.yml"
248
251
  - ".rubocop_todo.yml"
249
- - ".travis.yml"
250
252
  - ".yardopts"
251
253
  - Appraisals
252
254
  - CHANGELOG.md
@@ -258,15 +260,11 @@ files:
258
260
  - Rakefile
259
261
  - chewy.gemspec
260
262
  - filters
261
- - gemfiles/rails.4.0.activerecord.gemfile
262
- - gemfiles/rails.4.1.activerecord.gemfile
263
- - gemfiles/rails.4.2.activerecord.gemfile
264
- - gemfiles/rails.4.2.mongoid.5.2.gemfile
265
- - gemfiles/rails.5.0.activerecord.gemfile
266
- - gemfiles/rails.5.0.mongoid.6.1.gemfile
267
- - gemfiles/rails.5.1.activerecord.gemfile
268
- - gemfiles/rails.5.1.mongoid.6.3.gemfile
269
263
  - gemfiles/rails.5.2.activerecord.gemfile
264
+ - gemfiles/rails.5.2.mongoid.6.4.gemfile
265
+ - gemfiles/rails.6.0.activerecord.gemfile
266
+ - gemfiles/rails.6.1.activerecord.gemfile
267
+ - gemfiles/ruby3.gemfile
270
268
  - gemfiles/sequel.4.45.gemfile
271
269
  - lib/chewy.rb
272
270
  - lib/chewy/backports/deep_dup.rb
@@ -521,7 +519,7 @@ homepage: https://github.com/toptal/chewy
521
519
  licenses:
522
520
  - MIT
523
521
  metadata: {}
524
- post_install_message:
522
+ post_install_message:
525
523
  rdoc_options: []
526
524
  require_paths:
527
525
  - lib
@@ -536,8 +534,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
536
534
  - !ruby/object:Gem::Version
537
535
  version: '0'
538
536
  requirements: []
539
- rubygems_version: 3.0.6
540
- signing_key:
537
+ rubygems_version: 3.1.2
538
+ signing_key:
541
539
  specification_version: 4
542
540
  summary: Elasticsearch ODM client wrapper
543
541
  test_files:
@@ -1,45 +0,0 @@
1
- language: ruby
2
- sudo: false
3
- services:
4
- - mongodb
5
- jdk:
6
- - oraclejdk8
7
- rvm:
8
- - 2.4.3
9
- env:
10
- global:
11
- - TEST_CLUSTER_NODES=1
12
- matrix:
13
- - ES_VERSION=5.6.7
14
- gemfile:
15
- - gemfiles/rails.5.0.activerecord.gemfile
16
- - gemfiles/rails.5.1.activerecord.gemfile
17
- - gemfiles/rails.5.0.mongoid.6.1.gemfile
18
- - gemfiles/rails.5.1.mongoid.6.3.gemfile
19
- - gemfiles/sequel.4.45.gemfile
20
- matrix:
21
- include:
22
- - rvm: 2.2.9
23
- gemfile: gemfiles/rails.4.0.activerecord.gemfile
24
- env: ES_VERSION=2.4.6
25
- - rvm: 2.2.9
26
- gemfile: gemfiles/rails.4.1.activerecord.gemfile
27
- env: ES_VERSION=2.4.6
28
- - rvm: 2.3.6
29
- gemfile: gemfiles/rails.4.2.activerecord.gemfile
30
- env: ES_VERSION=2.4.6
31
- - rvm: 2.3.6
32
- gemfile: gemfiles/rails.4.2.mongoid.5.2.gemfile
33
- env: ES_VERSION=2.4.6
34
- - rvm: 2.5.1
35
- gemfile: gemfiles/rails.5.2.activerecord.gemfile
36
- env: ES_VERSION=5.6.7
37
- before_install:
38
- - curl -s https://download.elasticsearch.org/elasticsearch/release/org/elasticsearch/distribution/tar/elasticsearch/2.4.6/elasticsearch-2.4.6.tar.gz | tar xz -C /tmp
39
- - curl -s https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-5.6.7.tar.gz | tar xz -C /tmp
40
- before_script:
41
- - /tmp/elasticsearch-2.4.6/bin/plugin install delete-by-query
42
- - TEST_CLUSTER_COMMAND=/tmp/elasticsearch-$ES_VERSION/bin/elasticsearch TEST_CLUSTER_LOGS=/tmp/log rake es:start
43
- script:
44
- - bundle exec rspec
45
- - bundle exec rubocop
@@ -1,15 +0,0 @@
1
- # This file was generated by Appraisal
2
-
3
- source "https://rubygems.org"
4
-
5
- gem "activerecord", "~> 4.0.0"
6
- gem "activesupport", "~> 4.0.0"
7
- gem "resque", require: false
8
- gem "shoryuken", require: false
9
- gem "aws-sdk-sqs", require: false
10
- gem "sidekiq", require: false
11
- gem "kaminari", "~> 0.17.0", require: false
12
- gem "will_paginate", require: false
13
- gem "parallel", require: false
14
-
15
- gemspec path: "../"
@@ -1,15 +0,0 @@
1
- # This file was generated by Appraisal
2
-
3
- source "https://rubygems.org"
4
-
5
- gem "activerecord", "~> 4.1.0"
6
- gem "activesupport", "~> 4.1.0"
7
- gem "resque", require: false
8
- gem "shoryuken", require: false
9
- gem "aws-sdk-sqs", require: false
10
- gem "sidekiq", require: false
11
- gem "kaminari", "~> 0.17.0", require: false
12
- gem "will_paginate", require: false
13
- gem "parallel", require: false
14
-
15
- gemspec path: "../"
@@ -1,16 +0,0 @@
1
- # This file was generated by Appraisal
2
-
3
- source "https://rubygems.org"
4
-
5
- gem "activerecord", "~> 4.2.0"
6
- gem "activesupport", "~> 4.2.0"
7
- gem "activejob", "~> 4.2.0"
8
- gem "resque", require: false
9
- gem "shoryuken", require: false
10
- gem "aws-sdk-sqs", require: false
11
- gem "sidekiq", require: false
12
- gem "kaminari", "~> 0.17.0", require: false
13
- gem "will_paginate", require: false
14
- gem "parallel", require: false
15
-
16
- gemspec path: "../"
@@ -1,16 +0,0 @@
1
- # This file was generated by Appraisal
2
-
3
- source "https://rubygems.org"
4
-
5
- gem "mongoid", "~> 5.2.0"
6
- gem "activesupport", "~> 4.2.0"
7
- gem "activejob", "~> 4.2.0"
8
- gem "resque", require: false
9
- gem "shoryuken", require: false
10
- gem "aws-sdk-sqs", require: false
11
- gem "sidekiq", require: false
12
- gem "kaminari", "~> 0.17.0", require: false
13
- gem "will_paginate", require: false
14
- gem "parallel", require: false
15
-
16
- gemspec path: "../"
@@ -1,16 +0,0 @@
1
- # This file was generated by Appraisal
2
-
3
- source "https://rubygems.org"
4
-
5
- gem "mongoid", "~> 6.3.0"
6
- gem "activesupport", "~> 5.1.0"
7
- gem "activejob", "~> 5.1.0"
8
- gem "resque", require: false
9
- gem "shoryuken", require: false
10
- gem "aws-sdk-sqs", require: false
11
- gem "sidekiq", require: false
12
- gem "kaminari-core", "~> 1.1.0", require: false
13
- gem "will_paginate", require: false
14
- gem "parallel", require: false
15
-
16
- gemspec path: "../"