diff options
author | Tim Smith <tsmith@chef.io> | 2020-01-30 16:47:55 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-01-30 16:47:55 -0800 |
commit | 5ef37942c3124df9f85d76b9f8e9b18d0e87c581 (patch) | |
tree | a70fdcb1f6b96ff2e62c2185f8c722d509bca5ba | |
parent | 2ccd40f3a2e84c1f6e3608f5e6e3a2d1169941b0 (diff) | |
parent | 4a677eaebff35a81b3f3ebc3c990d10e2d13307b (diff) | |
download | chef-5ef37942c3124df9f85d76b9f8e9b18d0e87c581.tar.gz |
Merge pull request #9308 from chef/fuzzy_search
Fix fuzzy node search to work when the search type is a string rather than a symbol
-rw-r--r-- | lib/chef/search/query.rb | 2 | ||||
-rw-r--r-- | spec/unit/search/query_spec.rb | 9 |
2 files changed, 9 insertions, 2 deletions
diff --git a/lib/chef/search/query.rb b/lib/chef/search/query.rb index 46dedd33f8..fa758fc274 100644 --- a/lib/chef/search/query.rb +++ b/lib/chef/search/query.rb @@ -63,7 +63,7 @@ class Chef args_h = hashify_args(*args) if args_h[:fuzz] - if type == :node + if type.to_sym == :node query = fuzzify_node_query(query) end # FIXME: can i haz proper ruby-2.x named parameters someday plz? diff --git a/spec/unit/search/query_spec.rb b/spec/unit/search/query_spec.rb index 83f988911c..ed970af2df 100644 --- a/spec/unit/search/query_spec.rb +++ b/spec/unit/search/query_spec.rb @@ -233,13 +233,20 @@ describe Chef::Search::Query do end end - it "fuzzifies node searches when fuzz is set" do + it "fuzzifies node searches when fuzz is set and type is a symbol" do expect(rest).to receive(:get).with( "search/node?q=tags:*free.messi*%20OR%20roles:*free.messi*%20OR%20fqdn:*free.messi*%20OR%20addresses:*free.messi*%20OR%20policy_name:*free.messi*%20OR%20policy_group:*free.messi*&start=0&rows=#{default_rows}" ).and_return(response) query.search(:node, "free.messi", fuzz: true) end + it "fuzzifies node searches when fuzz is set and type is a string" do + expect(rest).to receive(:get).with( + "search/node?q=tags:*free.messi*%20OR%20roles:*free.messi*%20OR%20fqdn:*free.messi*%20OR%20addresses:*free.messi*%20OR%20policy_name:*free.messi*%20OR%20policy_group:*free.messi*&start=0&rows=#{default_rows}" + ).and_return(response) + query.search("node", "free.messi", fuzz: true) + end + it "does not fuzzify node searches when fuzz is not set" do expect(rest).to receive(:get).with( "search/node?q=free.messi&start=0&rows=#{default_rows}" |