From 096fbde5db1a588e768de9fb23b0812ca9e745fd Mon Sep 17 00:00:00 2001 From: Matt Larraz Date: Thu, 25 Apr 2024 12:37:15 -0400 Subject: [PATCH] Fix incorrect variable name (#247) * Fix incorrect variable name Signed-off-by: Matt Larraz * # Added tests Signed-off-by: Theo Truong * # Updated CHANGELOG.md Signed-off-by: Theo Truong * # Added License header Signed-off-by: Theo Truong --------- Signed-off-by: Matt Larraz Signed-off-by: Theo Truong Co-authored-by: Theo Truong --- CHANGELOG.md | 1 + lib/opensearch.rb | 2 +- lib/opensearch/dsl/search.rb | 2 +- .../client/unit/opensearch_client_spec.rb | 18 ++++++++++++++++++ 4 files changed, 21 insertions(+), 2 deletions(-) create mode 100644 spec/opensearch/client/unit/opensearch_client_spec.rb diff --git a/CHANGELOG.md b/CHANGELOG.md index 36a1de536..c1bfc7668 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) ### Deprecated ### Removed ### Fixed +- Fixed variable name in `OpenSearch::Client#respond_to_missing?` ([#247](https://github.com/opensearch-project/opensearch-ruby/pull/247)) ### Security ## [3.2.0] diff --git a/lib/opensearch.rb b/lib/opensearch.rb index 7f97f2daa..3ea553b16 100644 --- a/lib/opensearch.rb +++ b/lib/opensearch.rb @@ -49,7 +49,7 @@ def method_missing(name, *args, &block) end def respond_to_missing?(method_name, include_private = false) - name == :perform_request || super + method_name == :perform_request || super end private diff --git a/lib/opensearch/dsl/search.rb b/lib/opensearch/dsl/search.rb index 19c05e7ce..987820582 100644 --- a/lib/opensearch/dsl/search.rb +++ b/lib/opensearch/dsl/search.rb @@ -250,7 +250,7 @@ def method_missing(name, *args, &block) end def respond_to_missing?(method_name, include_private = false) - @options.respond_to?(name) || super + @options.respond_to?(method_name) || super end # Converts the search definition to a Hash diff --git a/spec/opensearch/client/unit/opensearch_client_spec.rb b/spec/opensearch/client/unit/opensearch_client_spec.rb new file mode 100644 index 000000000..c43290714 --- /dev/null +++ b/spec/opensearch/client/unit/opensearch_client_spec.rb @@ -0,0 +1,18 @@ +# SPDX-License-Identifier: Apache-2.0 +# +# The OpenSearch Contributors require contributions made to +# this file be licensed under the Apache-2.0 license or a +# compatible open source license. +# +# Modifications Copyright OpenSearch Contributors. See +# GitHub history for details. + +require_relative '../../../spec_helper' + +describe 'OpenSearch::Client#respond_to_missing?' do + it 'returns to correct results' do + client = OpenSearch::Client.new + expect(client.send(:respond_to_missing?, :perform_request)).to be true + expect(client.send(:respond_to_missing?, :something_else)).to be false + end +end