diff options
-rw-r--r-- | lib/puppet/network/http/api/v1.rb | 4 | ||||
-rw-r--r-- | spec/unit/network/http/api/v1_spec.rb | 12 |
2 files changed, 14 insertions, 2 deletions
diff --git a/lib/puppet/network/http/api/v1.rb b/lib/puppet/network/http/api/v1.rb index 0a04a465f..9e51aae36 100644 --- a/lib/puppet/network/http/api/v1.rb +++ b/lib/puppet/network/http/api/v1.rb @@ -63,9 +63,9 @@ module Puppet::Network::HTTP::API::V1 return :singular if indirection == "status" return :plural if indirection == "inventory" - result = (indirection =~ /s$/) ? :plural : :singular + result = (indirection =~ /s$|_search$/) ? :plural : :singular - indirection.sub!(/s$/, '') if result + indirection.sub!(/s$|_search$|es$/, '') result end diff --git a/spec/unit/network/http/api/v1_spec.rb b/spec/unit/network/http/api/v1_spec.rb index d47fc8d81..e7348312b 100644 --- a/spec/unit/network/http/api/v1_spec.rb +++ b/spec/unit/network/http/api/v1_spec.rb @@ -88,6 +88,18 @@ describe Puppet::Network::HTTP::API::V1 do @tester.uri2indirection("GET", "/env/inventory/search", {}).method.should == :search end + it "should choose 'search' as the indirection method if the http method is a GET and the indirection name is facts_search" do + @tester.uri2indirection("GET", "/env/facts_search/bar", {}).method.should == :search + end + + it "should change indirection name to 'facts' if the http method is a GET and the indirection name is facts_search" do + @tester.uri2indirection("GET", "/env/facts_search/bar", {}).indirection_name.should == :facts + end + + it "should change indirection name to 'status' if the http method is a GEt and the indirection name is statuses" do + @tester.uri2indirection("GET", "/env/statuses/bar", {}).indirection_name.should == :status + end + it "should choose 'delete' as the indirection method if the http method is a DELETE and the indirection name is singular" do @tester.uri2indirection("DELETE", "/env/foo/bar", {}).method.should == :destroy end |