From c64b6d9f430aefd8a6168e49ba09ca726cdb1556 Mon Sep 17 00:00:00 2001 From: Joe Rafaniello Date: Tue, 26 Nov 2024 10:44:15 -0500 Subject: [PATCH] Treat result of to_h to be hashes recursively Config gem version 3.0 removed the dot access from .to_h resulting values intentionally. See: https://www.github.com/rubyconfig/config/issues/217 In config 2.2.3, the result of: ``` Api::ApiConfig.collections.to_h ``` was: ``` (byebug) Api::ApiConfig.collections.to_h {:accounts=>#, :actions=>#{:description=>"Accounts", :options=>[:subcollection], :verbs=>[:get], :klass=>"Account"}, :actions=>{:description=>"Actions", :identifier=>"miq_action", :options=>[:collection], :verbs=>[:get, :put, :post, :patch, :delete], ... ``` Note, if you don't convert to hash, you retain the Config::Options structure and API: ``` (byebug) Api::ApiConfig.collections ... ``` It's easy enough to change the access to assume nested hashes all the way down, which is also compatible with existing Config::Options behavior. --- spec/requests/authentication_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/requests/authentication_spec.rb b/spec/requests/authentication_spec.rb index e7d58b8d2f..b022ebce50 100644 --- a/spec/requests/authentication_spec.rb +++ b/spec/requests/authentication_spec.rb @@ -75,7 +75,7 @@ get api_entrypoint_url - collection_names = Api::ApiConfig.collections.to_h.select { |_, v| v.options.include?(:collection) }.keys + collection_names = Api::ApiConfig.collections.to_h.select { |_, v| v[:options].include?(:collection) }.keys hrefs = collection_names.collect { |name| url_for(:controller => name, :action => "index") } expected = { "collections" => a_collection_containing_exactly(