Commit 4c0c24378264f1e596968f904833db620871fb68
1 parent
3fcccf10
Exists in
master
and in
2 other branches
Added support for elasticsearch 8 gem [skip ci]
Showing
2 changed files
with
13 additions
and
3 deletions
Show diff stats
lib/searchkick.rb
... | ... | @@ -296,13 +296,15 @@ module Searchkick |
296 | 296 | |
297 | 297 | # private |
298 | 298 | def self.not_found_error?(e) |
299 | - (defined?(Elasticsearch) && e.is_a?(Elasticsearch::Transport::Transport::Errors::NotFound)) || | |
299 | + (defined?(Elastic::Transport) && e.is_a?(Elastic::Transport::Transport::Errors::NotFound)) || | |
300 | + (defined?(Elasticsearch::Transport) && e.is_a?(Elasticsearch::Transport::Transport::Errors::NotFound)) || | |
300 | 301 | (defined?(OpenSearch) && e.is_a?(OpenSearch::Transport::Transport::Errors::NotFound)) |
301 | 302 | end |
302 | 303 | |
303 | 304 | # private |
304 | 305 | def self.transport_error?(e) |
305 | - (defined?(Elasticsearch) && e.is_a?(Elasticsearch::Transport::Transport::Error)) || | |
306 | + (defined?(Elastic::Transport) && e.is_a?(Elastic::Transport::Transport::Error)) || | |
307 | + (defined?(Elasticsearch::Transport) && e.is_a?(Elasticsearch::Transport::Transport::Error)) || | |
306 | 308 | (defined?(OpenSearch) && e.is_a?(OpenSearch::Transport::Transport::Error)) |
307 | 309 | end |
308 | 310 | end | ... | ... |
test/search_test.rb
... | ... | @@ -67,7 +67,15 @@ class SearchTest < Minitest::Test |
67 | 67 | end |
68 | 68 | |
69 | 69 | def test_unsupported_version |
70 | - raises_exception = ->(_) { raise Elasticsearch::Transport::Transport::Error, "[500] No query registered for [multi_match]" } | |
70 | + skip if Searchkick.opensearch? | |
71 | + | |
72 | + raises_exception = lambda do |*| | |
73 | + if defined?(Elastic::Transport) | |
74 | + raise Elastic::Transport::Transport::Error, "[500] No query registered for [multi_match]" | |
75 | + else | |
76 | + raise Elasticsearch::Transport::Transport::Error, "[500] No query registered for [multi_match]" | |
77 | + end | |
78 | + end | |
71 | 79 | Searchkick.client.stub :search, raises_exception do |
72 | 80 | assert_raises(Searchkick::UnsupportedVersionError) { Product.search("test") } |
73 | 81 | end | ... | ... |