Skip to content

Commit

Permalink
Move preference to query params (#816)
Browse files Browse the repository at this point in the history
  • Loading branch information
afg419 authored Sep 22, 2021
1 parent c9d1159 commit dfcd4b0
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 8 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
### Changes

### Bugs Fixed
* [#816](https://github.com/toptal/chewy/pull/816): Move query [`preference`](https://www.elastic.co/guide/en/elasticsearch/reference/7.x/search-search.html#search-preference) from body to query parameters. ([@afg419][])

## 7.2.2 (2021-05-24)

Expand Down Expand Up @@ -624,6 +625,7 @@
[@aglushkov]: https://github.com/aglushkov
[@AlexVPopov]: https://github.com/AlexVPopov
[@AndreySavelyev]: https://github.com/AndreySavelyev
[@afg419]: https://github.com/afg419
[@arion]: https://github.com/arion
[@arturtr]: https://github.com/arturtr
[@averell23]: https://github.com/averell23
Expand Down
2 changes: 1 addition & 1 deletion lib/chewy/search/parameters.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ module Search
# @see Chewy::Search::Request#parameters
# @see Chewy::Search::Parameters::Storage
class Parameters
QUERY_STRING_STORAGES = %i[indices search_type request_cache allow_partial_search_results].freeze
QUERY_STRING_STORAGES = %i[indices preference search_type request_cache allow_partial_search_results].freeze

# Default storage classes warehouse. It is probably possible to
# add your own classes here if necessary, but I'm not sure it will work.
Expand Down
19 changes: 12 additions & 7 deletions spec/chewy/search/request_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -214,13 +214,18 @@
specify { expect { subject.search_type('foo') }.not_to change { subject.render } }
end

%i[preference timeout].each do |name|
describe "##{name}" do
specify { expect(subject.send(name, :foo).render[:body]).to include(name => 'foo') }
specify { expect(subject.send(name, :foo).send(name, :bar).render[:body]).to include(name => 'bar') }
specify { expect(subject.send(name, :foo).send(name, nil).render[:body]).to be_blank }
specify { expect { subject.send(name, :foo) }.not_to change { subject.render } }
end
describe '#preference' do
specify { expect(subject.preference('foo').render).to include(preference: 'foo') }
specify { expect(subject.preference('foo').preference('bar').render).to include(preference: 'bar') }
specify { expect(subject.preference('foo').preference(nil).render[:preference]).to be_blank }
specify { expect { subject.preference('foo') }.not_to change { subject.render } }
end

describe "#timeout" do
specify { expect(subject.timeout(:foo).render[:body]).to include(timeout: 'foo') }
specify { expect(subject.timeout(:foo).timeout(:bar).render[:body]).to include(timeout: 'bar') }
specify { expect(subject.timeout(:foo).timeout(nil).render[:body]).to be_blank }
specify { expect { subject.timeout(:foo) }.not_to change { subject.render } }
end

describe '#source' do
Expand Down

0 comments on commit dfcd4b0

Please sign in to comment.