Skip to content

Commit

Permalink
Fix in mock_elasticsearch_response_sources (#861)
Browse files Browse the repository at this point in the history
* Fix for incremental id in mock_elasticsearch_response_sources

* Modifies test so it passes when id matches source id.

* Adds changelog entry
  • Loading branch information
lafeber authored Apr 20, 2023
1 parent 7fb0b50 commit c20d112
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
* [#874](https://github.com/toptal/chewy/pull/874): Fix `chewy:journal:clean` task for ruby 3.x. ([@muk-ai](https://github.com/muk-ai))
* [#882](https://github.com/toptal/chewy/pull/882): Fix memory leak during `chewy:reset` for ruby 3.2 ([@konalegi](https://github.com/konalegi))

* [#861](https://github.com/toptal/chewy/pull/861): Fix bug in mock_elasticsearch_response_sources ([@lafeber](https://github.com/lafeber))

## 7.3.0 (2023-04-03)

### New Features
Expand Down
2 changes: 1 addition & 1 deletion lib/chewy/minitest/helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ def mock_elasticsearch_response_sources(index, hits, &block)
{
'_index' => index.index_name,
'_type' => '_doc',
'_id' => (i + 1).to_s,
'_id' => hit[:id] || (i + 1).to_s,
'_score' => 3.14,
'_source' => hit
}
Expand Down
4 changes: 2 additions & 2 deletions spec/chewy/minitest/helpers_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,14 @@ def assert_equal(expected, actual, message)
{
'_index' => 'dummies',
'_type' => '_doc',
'_id' => '1',
'_id' => '2',
'_score' => 3.14,
'_source' => source
}
]
end

let(:source) { {'name' => 'some_name'} }
let(:source) { {'name' => 'some_name', id: '2'} }
let(:sources) { [source] }

context 'mocks by raw response' do
Expand Down

0 comments on commit c20d112

Please sign in to comment.