From b81a6d71316f735a6688ee6e8a6ed659d474be1b Mon Sep 17 00:00:00 2001 From: Ivan Rabotyaga Date: Thu, 11 Feb 2021 17:07:24 +0300 Subject: [PATCH] Add a changelog entry, update specs --- CHANGELOG.md | 2 ++ spec/chewy/multi_search_spec.rb | 20 ++++++++++---------- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3fbf98b3c..4aa390fcc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,7 @@ ## Changes + * [#751](https://github.com/toptal/chewy/pull/751): Add [Multi Search API](https://www.elastic.co/guide/en/elasticsearch/reference/6.8/search-multi-search.html) support ([@mpeychich][], [@dalthon][]) * [#755](https://github.com/toptal/chewy/pull/755): `attribute_highlights` returns an array of highlights ([@musaffa][], [@dalthon][]) * [#753](https://github.com/toptal/chewy/pull/753): Add support for direct_import parameter to skip objects reloading ([@TikiTDO][], [@dalthon][]) * [#739](https://github.com/toptal/chewy/pull/739): Remove explicit `main` branch dependencies on rspec* gems after `rspec-mocks` 3.10.2 is released ([@rabotyaga][]) @@ -560,6 +561,7 @@ [@menglewis]: https://github.com/menglewis [@mikeyhogarth]: https://github.com/mikeyhogarth [@mkcode]: https://github.com/mkcode +[@mpeychich]: https://github.com/mpeychich [@mrbrdo]: https://github.com/mrbrdo [@mrzasa]: https://github.com/mrzasa [@musaffa]: https://github.com/musaffa diff --git a/spec/chewy/multi_search_spec.rb b/spec/chewy/multi_search_spec.rb index d6f847a3d..ea82eb601 100644 --- a/spec/chewy/multi_search_spec.rb +++ b/spec/chewy/multi_search_spec.rb @@ -8,19 +8,19 @@ stub_model(:city) stub_model(:country) - stub_index(:places) do + stub_index(:cities) do + def self.aggregate_by_country + aggs(country: {terms: {field: :country_id}}) + end + define_type City do field :name, type: 'keyword' field :country_id, type: 'keyword' - - def self.aggregate_by_country - aggs(country: {terms: {field: :country_id}}) - end end end end - let(:places_query) { PlacesIndex.all } + let(:places_query) { CitiesIndex.all } describe '#queries' do specify 'returns the queries that are a part of the multi search' do @@ -42,11 +42,11 @@ def self.aggregate_by_country context 'when given two queries' do let(:queries) { [aggregates, results] } - let(:aggregates) { PlacesIndex::City.aggregate_by_country.limit(0) } - let(:results) { PlacesIndex::City.limit(10) } + let(:aggregates) { CitiesIndex.aggregate_by_country.limit(0) } + let(:results) { CitiesIndex.limit(10) } let(:multi_search) { described_class.new(queries) } let(:cities) { Array.new(3) { |i| City.create! name: "Name#{i + 2}", country_id: i + 1 } } - before { PlacesIndex.import! city: cities } + before { CitiesIndex.import! city: cities } describe '#perform' do specify 'performs each query' do @@ -78,7 +78,7 @@ def self.aggregate_by_country is_expected.to have(2).responses expect(responses[0]).to be_a(Chewy::Search::Response) expect(responses[1]).to be_a(Chewy::Search::Response) - expect(responses[1].wrappers).to all(be_a PlacesIndex::City) + expect(responses[1].wrappers).to all(be_a CitiesIndex::City) end end end