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.
- checksums.yaml +4 -4
- data/.circleci/config.yml +214 -0
- data/CHANGELOG.md +26 -0
- data/Gemfile +2 -0
- data/LICENSE.txt +1 -1
- data/README.md +60 -34
- data/chewy.gemspec +4 -4
- data/gemfiles/rails.5.2.activerecord.gemfile +1 -0
- data/gemfiles/{rails.5.0.activerecord.gemfile → rails.5.2.mongoid.6.4.gemfile} +4 -3
- data/gemfiles/{rails.5.0.mongoid.6.1.gemfile → rails.6.0.activerecord.gemfile} +4 -3
- data/gemfiles/{rails.5.1.activerecord.gemfile → rails.6.1.activerecord.gemfile} +6 -3
- data/gemfiles/ruby3.gemfile +10 -0
- data/lib/chewy.rb +1 -1
- data/lib/chewy/backports/duplicable.rb +1 -1
- data/lib/chewy/fields/base.rb +1 -1
- data/lib/chewy/fields/root.rb +2 -2
- data/lib/chewy/index/actions.rb +9 -3
- data/lib/chewy/query/loading.rb +1 -1
- data/lib/chewy/query/nodes/field.rb +1 -1
- data/lib/chewy/search/loader.rb +1 -1
- data/lib/chewy/search/parameters.rb +2 -1
- data/lib/chewy/search/request.rb +1 -0
- data/lib/chewy/strategy/active_job.rb +1 -1
- data/lib/chewy/strategy/sidekiq.rb +1 -1
- data/lib/chewy/type/adapter/active_record.rb +1 -1
- data/lib/chewy/type/adapter/mongoid.rb +1 -1
- data/lib/chewy/type/adapter/orm.rb +1 -1
- data/lib/chewy/type/adapter/sequel.rb +1 -1
- data/lib/chewy/type/import.rb +3 -3
- data/lib/chewy/type/import/routine.rb +1 -1
- data/lib/chewy/type/mapping.rb +4 -4
- data/lib/chewy/type/observe.rb +3 -3
- data/lib/chewy/type/witchcraft.rb +1 -1
- data/lib/chewy/version.rb +1 -1
- data/spec/chewy/config_spec.rb +1 -1
- data/spec/chewy/fields/base_spec.rb +11 -9
- data/spec/chewy/index/actions_spec.rb +2 -2
- data/spec/chewy/journal_spec.rb +1 -1
- data/spec/chewy/search/parameters_spec.rb +4 -2
- data/spec/chewy/search/response_spec.rb +8 -2
- data/spec/chewy/search_spec.rb +2 -2
- data/spec/chewy/strategy/active_job_spec.rb +15 -2
- data/spec/chewy/strategy/shoryuken_spec.rb +6 -2
- data/spec/chewy/strategy/sidekiq_spec.rb +6 -2
- data/spec/chewy/type/adapter/active_record_spec.rb +3 -3
- data/spec/chewy/type/import/bulk_builder_spec.rb +1 -1
- data/spec/chewy/type/observe_spec.rb +4 -4
- data/spec/spec_helper.rb +4 -1
- metadata +17 -19
- data/.travis.yml +0 -45
- data/gemfiles/rails.4.0.activerecord.gemfile +0 -15
- data/gemfiles/rails.4.1.activerecord.gemfile +0 -15
- data/gemfiles/rails.4.2.activerecord.gemfile +0 -16
- data/gemfiles/rails.4.2.mongoid.5.2.gemfile +0 -16
- data/gemfiles/rails.5.1.mongoid.6.3.gemfile +0 -16
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
source "https://rubygems.org"
|
|
4
4
|
|
|
5
|
-
gem "
|
|
6
|
-
gem "activesupport", "~> 5.
|
|
7
|
-
gem "activejob", "~> 5.
|
|
5
|
+
gem "mongoid", "~> 6.4.0"
|
|
6
|
+
gem "activesupport", "~> 5.2.0"
|
|
7
|
+
gem "activejob", "~> 5.2.0"
|
|
8
8
|
gem "resque", require: false
|
|
9
9
|
gem "shoryuken", require: false
|
|
10
10
|
gem "aws-sdk-sqs", require: false
|
|
@@ -12,5 +12,6 @@ gem "sidekiq", require: false
|
|
|
12
12
|
gem "kaminari-core", "~> 1.1.0", require: false
|
|
13
13
|
gem "will_paginate", require: false
|
|
14
14
|
gem "parallel", require: false
|
|
15
|
+
gem 'rspec_junit_formatter', '~> 0.4.1'
|
|
15
16
|
|
|
16
17
|
gemspec path: "../"
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
source "https://rubygems.org"
|
|
4
4
|
|
|
5
|
-
gem "
|
|
6
|
-
gem "activesupport", "~>
|
|
7
|
-
gem "activejob", "~>
|
|
5
|
+
gem "activerecord", "~> 6.0.0"
|
|
6
|
+
gem "activesupport", "~> 6.0.0"
|
|
7
|
+
gem "activejob", "~> 6.0.0"
|
|
8
8
|
gem "resque", require: false
|
|
9
9
|
gem "shoryuken", require: false
|
|
10
10
|
gem "aws-sdk-sqs", require: false
|
|
@@ -12,5 +12,6 @@ gem "sidekiq", require: false
|
|
|
12
12
|
gem "kaminari-core", "~> 1.1.0", require: false
|
|
13
13
|
gem "will_paginate", require: false
|
|
14
14
|
gem "parallel", require: false
|
|
15
|
+
gem 'rspec_junit_formatter', '~> 0.4.1'
|
|
15
16
|
|
|
16
17
|
gemspec path: "../"
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
source "https://rubygems.org"
|
|
4
4
|
|
|
5
|
-
gem "activerecord", "~>
|
|
6
|
-
gem "activesupport", "~>
|
|
7
|
-
gem "activejob", "~>
|
|
5
|
+
gem "activerecord", "~> 6.1.0"
|
|
6
|
+
gem "activesupport", "~> 6.1.0"
|
|
7
|
+
gem "activejob", "~> 6.1.0"
|
|
8
8
|
gem "resque", require: false
|
|
9
9
|
gem "shoryuken", require: false
|
|
10
10
|
gem "aws-sdk-sqs", require: false
|
|
@@ -12,5 +12,8 @@ gem "sidekiq", require: false
|
|
|
12
12
|
gem "kaminari-core", "~> 1.1.0", require: false
|
|
13
13
|
gem "will_paginate", require: false
|
|
14
14
|
gem "parallel", require: false
|
|
15
|
+
gem 'rspec_junit_formatter', '~> 0.4.1'
|
|
16
|
+
|
|
17
|
+
eval(File.read('gemfiles/ruby3.gemfile'), nil, 'gemfiles/ruby3.gemfile') if RUBY_VERSION >= '3.0.0'
|
|
15
18
|
|
|
16
19
|
gemspec path: "../"
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
# kwargs support was added here:
|
|
2
|
+
# https://github.com/rspec/rspec-mocks/blob/main/lib/rspec/mocks/method_double.rb#L66
|
|
3
|
+
# but this change was not released yet so for the time being use main branch
|
|
4
|
+
gem 'rspec', github: 'rspec/rspec', branch: 'main'
|
|
5
|
+
gem 'rspec-core', github: 'rspec/rspec-core', branch: 'main'
|
|
6
|
+
gem 'rspec-expectations', github: 'rspec/rspec-expectations', branch: 'main'
|
|
7
|
+
gem 'rspec-mocks', github: 'rspec/rspec-mocks', branch: 'main'
|
|
8
|
+
gem 'rspec-support', github: 'rspec/rspec-support', branch: 'main'
|
|
9
|
+
# extracted from stdlib
|
|
10
|
+
gem 'rexml'
|
data/lib/chewy.rb
CHANGED
|
@@ -132,7 +132,7 @@ module Chewy
|
|
|
132
132
|
def create_type(index, target, options = {}, &block)
|
|
133
133
|
type = Class.new(Chewy::Type)
|
|
134
134
|
|
|
135
|
-
adapter = adapters.find { |klass| klass.accepts?(target) }.new(target, options)
|
|
135
|
+
adapter = adapters.find { |klass| klass.accepts?(target) }.new(target, **options)
|
|
136
136
|
|
|
137
137
|
index.const_set(adapter.name, type)
|
|
138
138
|
type.send(:define_singleton_method, :index) { index }
|
data/lib/chewy/fields/base.rb
CHANGED
data/lib/chewy/fields/root.rb
CHANGED
data/lib/chewy/index/actions.rb
CHANGED
|
@@ -30,8 +30,8 @@ module Chewy
|
|
|
30
30
|
# Suffixed index names might be used for zero-downtime mapping change, for example.
|
|
31
31
|
# Description: (http://www.elasticsearch.org/blog/changing-mapping-with-zero-downtime/).
|
|
32
32
|
#
|
|
33
|
-
def create(*args)
|
|
34
|
-
create!(*args)
|
|
33
|
+
def create(*args, **kwargs)
|
|
34
|
+
create!(*args, **kwargs)
|
|
35
35
|
rescue Elasticsearch::Transport::Transport::Errors::BadRequest
|
|
36
36
|
false
|
|
37
37
|
end
|
|
@@ -74,7 +74,13 @@ module Chewy
|
|
|
74
74
|
# UsersIndex.delete '01-2014' # deletes `users_01-2014` index
|
|
75
75
|
#
|
|
76
76
|
def delete(suffix = nil)
|
|
77
|
-
|
|
77
|
+
# Verify that the index_name is really the index_name and not an alias.
|
|
78
|
+
#
|
|
79
|
+
# "The index parameter in the delete index API no longer accepts alias names.
|
|
80
|
+
# Instead, it accepts only index names (or wildcards which will expand to matching indices)."
|
|
81
|
+
# https://www.elastic.co/guide/en/elasticsearch/reference/6.8/breaking-changes-6.0.html#_delete_index_api_resolves_indices_expressions_only_against_indices
|
|
82
|
+
index_names = client.indices.get_alias(index: index_name(suffix: suffix)).keys
|
|
83
|
+
result = client.indices.delete index: index_names.join(',')
|
|
78
84
|
Chewy.wait_for_status if result
|
|
79
85
|
result
|
|
80
86
|
# es-ruby >= 1.0.10 handles Elasticsearch::Transport::Transport::Errors::NotFound
|
data/lib/chewy/query/loading.rb
CHANGED
|
@@ -94,7 +94,7 @@ module Chewy
|
|
|
94
94
|
loaded_objects = Hash[_results.group_by(&:class).map do |type, objects|
|
|
95
95
|
next if except.include?(type.type_name)
|
|
96
96
|
next if only.present? && !only.include?(type.type_name)
|
|
97
|
-
loaded = type.adapter.load(objects.map(&:id), options.merge(_type: type)) || objects
|
|
97
|
+
loaded = type.adapter.load(objects.map(&:id), **options.merge(_type: type)) || objects
|
|
98
98
|
[type, loaded.index_by.with_index do |loaded_object, i|
|
|
99
99
|
objects[i]._object = loaded_object
|
|
100
100
|
objects[i]
|
|
@@ -39,7 +39,7 @@ module Chewy
|
|
|
39
39
|
when ::Regexp
|
|
40
40
|
Nodes::Regexp.new @name, other, *@args
|
|
41
41
|
when ::Range
|
|
42
|
-
Nodes::Range.new @name, *__options_merge__(gt: other.
|
|
42
|
+
Nodes::Range.new @name, *__options_merge__(gt: other.begin, lt: other.end)
|
|
43
43
|
else
|
|
44
44
|
if other.is_a?(Array) && other.first.is_a?(::Range)
|
|
45
45
|
Nodes::Range.new @name, *__options_merge__(
|
data/lib/chewy/search/loader.rb
CHANGED
|
@@ -52,7 +52,7 @@ module Chewy
|
|
|
52
52
|
|
|
53
53
|
type = derive_type(index_name, type_name)
|
|
54
54
|
ids = hit_group.map { |hit| hit['_id'] }
|
|
55
|
-
loaded = type.adapter.load(ids,
|
|
55
|
+
loaded = type.adapter.load(ids, **@options.merge(_type: type))
|
|
56
56
|
loaded ||= hit_group.map { |hit| type.build(hit) }
|
|
57
57
|
|
|
58
58
|
result.merge!(hit_group.zip(loaded).to_h)
|
|
@@ -35,10 +35,11 @@ module Chewy
|
|
|
35
35
|
# limit: Chewy::Search::Parameters::Offset.new(10)
|
|
36
36
|
# )
|
|
37
37
|
# @param initial [{Symbol => Object, Chewy::Search::Parameters::Storage}]
|
|
38
|
-
def initialize(initial = {})
|
|
38
|
+
def initialize(initial = {}, **kinitial)
|
|
39
39
|
@storages = Hash.new do |hash, name|
|
|
40
40
|
hash[name] = self.class.storages[name].new
|
|
41
41
|
end
|
|
42
|
+
initial = initial.deep_dup.merge(kinitial)
|
|
42
43
|
initial.each_with_object(@storages) do |(name, value), result|
|
|
43
44
|
storage_class = self.class.storages[name]
|
|
44
45
|
storage = value.is_a?(storage_class) ? value : storage_class.new(value)
|
data/lib/chewy/search/request.rb
CHANGED
|
@@ -11,7 +11,7 @@ module Chewy
|
|
|
11
11
|
#
|
|
12
12
|
class ActiveJob < Atomic
|
|
13
13
|
class Worker < ::ActiveJob::Base
|
|
14
|
-
queue_as :chewy
|
|
14
|
+
queue_as { Chewy.settings.dig(:active_job, :queue) || 'chewy' }
|
|
15
15
|
|
|
16
16
|
def perform(type, ids, options = {})
|
|
17
17
|
options[:refresh] = !Chewy.disable_refresh_async if Chewy.disable_refresh_async
|
|
@@ -22,7 +22,7 @@ module Chewy
|
|
|
22
22
|
end
|
|
23
23
|
|
|
24
24
|
def import_scope(scope, options)
|
|
25
|
-
pluck_in_batches(scope, options.slice(:batch_size)).inject(true) do |result, ids|
|
|
25
|
+
pluck_in_batches(scope, **options.slice(:batch_size)).inject(true) do |result, ids|
|
|
26
26
|
objects = if options[:raw_import]
|
|
27
27
|
raw_default_scope_where_ids_in(ids, options[:raw_import])
|
|
28
28
|
else
|
|
@@ -25,7 +25,7 @@ module Chewy
|
|
|
25
25
|
end
|
|
26
26
|
|
|
27
27
|
def import_scope(scope, options)
|
|
28
|
-
pluck_in_batches(scope, options.slice(:batch_size)).map do |ids|
|
|
28
|
+
pluck_in_batches(scope, **options.slice(:batch_size)).map do |ids|
|
|
29
29
|
yield grouped_objects(default_scope_where_ids_in(ids))
|
|
30
30
|
end.all?
|
|
31
31
|
end
|
|
@@ -89,7 +89,7 @@ module Chewy
|
|
|
89
89
|
|
|
90
90
|
if options[:fields].present? || collection.is_a?(relation_class)
|
|
91
91
|
collection = all_scope_where_ids_in(identify(collection)) unless collection.is_a?(relation_class)
|
|
92
|
-
pluck_in_batches(collection, options.slice(:fields, :batch_size, :typecast), &block)
|
|
92
|
+
pluck_in_batches(collection, **options.slice(:fields, :batch_size, :typecast), &block)
|
|
93
93
|
else
|
|
94
94
|
identify(collection).each_slice(options[:batch_size]) do |batch|
|
|
95
95
|
yield batch
|
|
@@ -22,7 +22,7 @@ module Chewy
|
|
|
22
22
|
end
|
|
23
23
|
|
|
24
24
|
def import_scope(scope, options)
|
|
25
|
-
pluck_in_batches(scope, options.slice(:batch_size)).inject(true) do |result, ids|
|
|
25
|
+
pluck_in_batches(scope, **options.slice(:batch_size)).inject(true) do |result, ids|
|
|
26
26
|
result & yield(grouped_objects(default_scope_where_ids_in(ids).all))
|
|
27
27
|
end
|
|
28
28
|
end
|
data/lib/chewy/type/import.rb
CHANGED
|
@@ -10,7 +10,7 @@ module Chewy
|
|
|
10
10
|
|
|
11
11
|
IMPORT_WORKER = lambda do |type, options, total, ids, index|
|
|
12
12
|
::Process.setproctitle("chewy [#{type}]: import data (#{index + 1}/#{total})")
|
|
13
|
-
routine = Routine.new(type, options)
|
|
13
|
+
routine = Routine.new(type, **options)
|
|
14
14
|
type.adapter.import(*ids, routine.options) do |action_objects|
|
|
15
15
|
routine.process(**action_objects)
|
|
16
16
|
end
|
|
@@ -19,7 +19,7 @@ module Chewy
|
|
|
19
19
|
|
|
20
20
|
LEFTOVERS_WORKER = lambda do |type, options, total, body, index|
|
|
21
21
|
::Process.setproctitle("chewy [#{type}]: import leftovers (#{index + 1}/#{total})")
|
|
22
|
-
routine = Routine.new(type, options)
|
|
22
|
+
routine = Routine.new(type, **options)
|
|
23
23
|
routine.perform_bulk(body)
|
|
24
24
|
routine.errors
|
|
25
25
|
end
|
|
@@ -127,7 +127,7 @@ module Chewy
|
|
|
127
127
|
|
|
128
128
|
def import_routine(*args)
|
|
129
129
|
return if args.first.blank? && !args.first.nil?
|
|
130
|
-
routine = Routine.new(self, args.extract_options!)
|
|
130
|
+
routine = Routine.new(self, **args.extract_options!)
|
|
131
131
|
routine.create_indexes!
|
|
132
132
|
|
|
133
133
|
if routine.parallel_options
|
|
@@ -66,7 +66,7 @@ module Chewy
|
|
|
66
66
|
def create_indexes!
|
|
67
67
|
Chewy::Stash::Journal.create if @options[:journal]
|
|
68
68
|
return if Chewy.configuration[:skip_index_creation_on_import]
|
|
69
|
-
@type.index.create!(
|
|
69
|
+
@type.index.create!(**@bulk_options.slice(:suffix)) unless @type.index.exists?
|
|
70
70
|
end
|
|
71
71
|
|
|
72
72
|
# The main process method. Converts passed objects to thr bulk request body,
|
data/lib/chewy/type/mapping.rb
CHANGED
|
@@ -35,8 +35,8 @@ module Chewy
|
|
|
35
35
|
# end
|
|
36
36
|
#
|
|
37
37
|
def root(**options)
|
|
38
|
-
self.root_object ||= Chewy::Fields::Root.new(type_name, Chewy.default_root_options.merge(options))
|
|
39
|
-
root_object.update_options!(options)
|
|
38
|
+
self.root_object ||= Chewy::Fields::Root.new(type_name, **Chewy.default_root_options.merge(options))
|
|
39
|
+
root_object.update_options!(**options)
|
|
40
40
|
yield if block_given?
|
|
41
41
|
root_object
|
|
42
42
|
end
|
|
@@ -126,9 +126,9 @@ module Chewy
|
|
|
126
126
|
#
|
|
127
127
|
def field(*args, **options, &block)
|
|
128
128
|
if args.size > 1
|
|
129
|
-
args.map { |name| field(name, options) }
|
|
129
|
+
args.map { |name| field(name, **options) }
|
|
130
130
|
else
|
|
131
|
-
expand_nested(Chewy::Fields::Base.new(args.first, options), &block)
|
|
131
|
+
expand_nested(Chewy::Fields::Base.new(args.first, **options), &block)
|
|
132
132
|
end
|
|
133
133
|
end
|
|
134
134
|
|
data/lib/chewy/type/observe.rb
CHANGED
|
@@ -63,10 +63,10 @@ module Chewy
|
|
|
63
63
|
update_proc = Observe.update_proc(type_name, *args, &block)
|
|
64
64
|
|
|
65
65
|
if Chewy.use_after_commit_callbacks
|
|
66
|
-
after_commit(callback_options, &update_proc)
|
|
66
|
+
after_commit(**callback_options, &update_proc)
|
|
67
67
|
else
|
|
68
|
-
after_save(callback_options, &update_proc)
|
|
69
|
-
after_destroy(callback_options, &update_proc)
|
|
68
|
+
after_save(**callback_options, &update_proc)
|
|
69
|
+
after_destroy(**callback_options, &update_proc)
|
|
70
70
|
end
|
|
71
71
|
end
|
|
72
72
|
end
|
data/lib/chewy/version.rb
CHANGED
data/spec/chewy/config_spec.rb
CHANGED
|
@@ -141,7 +141,7 @@ describe Chewy::Config do
|
|
|
141
141
|
context 'when Rails::VERSION constant is defined' do
|
|
142
142
|
it 'looks for configuration in "config/chewy.yml"' do
|
|
143
143
|
module Rails
|
|
144
|
-
VERSION = '5.1.
|
|
144
|
+
VERSION = '5.1.1'.freeze
|
|
145
145
|
|
|
146
146
|
def self.root
|
|
147
147
|
Pathname.new(__dir__)
|
|
@@ -180,43 +180,45 @@ describe Chewy::Fields::Base do
|
|
|
180
180
|
end
|
|
181
181
|
end
|
|
182
182
|
|
|
183
|
+
# rubocop:disable Style/BracesAroundHashParameters
|
|
183
184
|
specify do
|
|
184
|
-
expect(EventsIndex::Event.root.compose(
|
|
185
|
-
|
|
186
|
-
)).to eq('id' => 1, 'category' => {'id' => 2, 'licenses' => {'id' => 3, 'name' => 'Name'}})
|
|
185
|
+
expect(EventsIndex::Event.root.compose({
|
|
186
|
+
id: 1, category: {id: 2, licenses: {id: 3, name: 'Name'}}
|
|
187
|
+
})).to eq('id' => 1, 'category' => {'id' => 2, 'licenses' => {'id' => 3, 'name' => 'Name'}})
|
|
187
188
|
end
|
|
188
189
|
|
|
189
190
|
specify do
|
|
190
|
-
expect(EventsIndex::Event.root.compose(id: 1, category: [
|
|
191
|
+
expect(EventsIndex::Event.root.compose({id: 1, category: [
|
|
191
192
|
{id: 2, 'licenses' => {id: 3, name: 'Name1'}},
|
|
192
193
|
{id: 4, licenses: nil}
|
|
193
|
-
])).to eq('id' => 1, 'category' => [
|
|
194
|
+
]})).to eq('id' => 1, 'category' => [
|
|
194
195
|
{'id' => 2, 'licenses' => {'id' => 3, 'name' => 'Name1'}},
|
|
195
196
|
{'id' => 4, 'licenses' => nil.as_json}
|
|
196
197
|
])
|
|
197
198
|
end
|
|
198
199
|
|
|
199
200
|
specify do
|
|
200
|
-
expect(EventsIndex::Event.root.compose('id' => 1, category: {id: 2, licenses: [
|
|
201
|
+
expect(EventsIndex::Event.root.compose({'id' => 1, category: {id: 2, licenses: [
|
|
201
202
|
{id: 3, name: 'Name1'}, {id: 4, name: 'Name2'}
|
|
202
|
-
]})).to eq('id' => 1, 'category' => {'id' => 2, 'licenses' => [
|
|
203
|
+
]}})).to eq('id' => 1, 'category' => {'id' => 2, 'licenses' => [
|
|
203
204
|
{'id' => 3, 'name' => 'Name1'}, {'id' => 4, 'name' => 'Name2'}
|
|
204
205
|
]})
|
|
205
206
|
end
|
|
206
207
|
|
|
207
208
|
specify do
|
|
208
|
-
expect(EventsIndex::Event.root.compose(id: 1, category: [
|
|
209
|
+
expect(EventsIndex::Event.root.compose({id: 1, category: [
|
|
209
210
|
{id: 2, licenses: [
|
|
210
211
|
{id: 3, 'name' => 'Name1'}, {id: 4, name: 'Name2'}
|
|
211
212
|
]},
|
|
212
213
|
{id: 5, licenses: []}
|
|
213
|
-
])).to eq('id' => 1, 'category' => [
|
|
214
|
+
]})).to eq('id' => 1, 'category' => [
|
|
214
215
|
{'id' => 2, 'licenses' => [
|
|
215
216
|
{'id' => 3, 'name' => 'Name1'}, {'id' => 4, 'name' => 'Name2'}
|
|
216
217
|
]},
|
|
217
218
|
{'id' => 5, 'licenses' => []}
|
|
218
219
|
])
|
|
219
220
|
end
|
|
221
|
+
# rubocop:enable Style/BracesAroundHashParameters
|
|
220
222
|
|
|
221
223
|
specify do
|
|
222
224
|
expect(EventsIndex::Event.root.compose(
|
|
@@ -55,7 +55,7 @@ describe Chewy::Index::Actions do
|
|
|
55
55
|
context do
|
|
56
56
|
before { DummiesIndex.create }
|
|
57
57
|
specify do
|
|
58
|
-
expect { DummiesIndex.create! }.to raise_error(Elasticsearch::Transport::Transport::Errors::BadRequest).with_message(/
|
|
58
|
+
expect { DummiesIndex.create! }.to raise_error(Elasticsearch::Transport::Transport::Errors::BadRequest).with_message(/already exists.*dummies/)
|
|
59
59
|
end
|
|
60
60
|
specify { expect { DummiesIndex.create!('2013') }.to raise_error(Elasticsearch::Transport::Transport::Errors::BadRequest).with_message(/Invalid alias name \[dummies\]/) }
|
|
61
61
|
end
|
|
@@ -67,7 +67,7 @@ describe Chewy::Index::Actions do
|
|
|
67
67
|
specify { expect(DummiesIndex.aliases).to eq([]) }
|
|
68
68
|
specify { expect(DummiesIndex.indexes).to eq(['dummies_2013']) }
|
|
69
69
|
specify do
|
|
70
|
-
expect { DummiesIndex.create!('2013') }.to raise_error(Elasticsearch::Transport::Transport::Errors::BadRequest).with_message(/
|
|
70
|
+
expect { DummiesIndex.create!('2013') }.to raise_error(Elasticsearch::Transport::Transport::Errors::BadRequest).with_message(/already exists.*dummies_2013/)
|
|
71
71
|
end
|
|
72
72
|
specify { expect(DummiesIndex.create!('2014')['acknowledged']).to eq(true) }
|
|
73
73
|
|
data/spec/chewy/journal_spec.rb
CHANGED
|
@@ -54,7 +54,7 @@ describe Chewy::Journal do
|
|
|
54
54
|
expect(Chewy::Stash::Journal.exists?).to eq true
|
|
55
55
|
|
|
56
56
|
Timecop.freeze(update_time)
|
|
57
|
-
cities.first.
|
|
57
|
+
cities.first.update!(name: 'Supername')
|
|
58
58
|
|
|
59
59
|
Timecop.freeze(destroy_time)
|
|
60
60
|
countries.last.destroy
|
|
@@ -72,18 +72,20 @@ describe Chewy::Search::Parameters do
|
|
|
72
72
|
describe '#merge!' do
|
|
73
73
|
let(:first) { described_class.new(offset: 10, order: 'foo') }
|
|
74
74
|
let(:second) { described_class.new(limit: 20, offset: 20, order: 'bar') }
|
|
75
|
+
let(:first_clone) { first.clone }
|
|
76
|
+
let(:second_clone) { second.clone }
|
|
75
77
|
|
|
76
78
|
specify do
|
|
77
79
|
expect { first.merge!(second) }.to change { first.clone }
|
|
78
80
|
.to(described_class.new(limit: 20, offset: 20, order: %w[foo bar]))
|
|
79
81
|
end
|
|
80
|
-
specify { expect { first.merge!(second) }.not_to change {
|
|
82
|
+
specify { expect { first.merge!(second) }.not_to change { second_clone } }
|
|
81
83
|
|
|
82
84
|
specify do
|
|
83
85
|
expect { second.merge!(first) }.to change { second.clone }
|
|
84
86
|
.to(described_class.new(limit: 20, offset: 10, order: %w[bar foo]))
|
|
85
87
|
end
|
|
86
|
-
specify { expect { second.merge!(first) }.not_to change {
|
|
88
|
+
specify { expect { second.merge!(first) }.not_to change { first_clone } }
|
|
87
89
|
|
|
88
90
|
context 'spawns new storages for the merge' do
|
|
89
91
|
let(:names) { %i[limit offset order] }
|