diff options
| author | Nick Lewis <nick@puppetlabs.com> | 2011-04-12 17:11:02 -0700 |
|---|---|---|
| committer | Nick Lewis <nick@puppetlabs.com> | 2011-04-12 17:11:02 -0700 |
| commit | d748338e69b705585f9ac6bf2fd8da1e9163839b (patch) | |
| tree | 8cd3d4a945fd5df18317db51fabd3f27767d9db4 /spec/unit/network/http/api | |
| parent | 40adee4ade3a447a7397a71d76e042091bbbfbff (diff) | |
| parent | 46721411066926aff3a7d5bb6470d3b8aec1b47d (diff) | |
Merge branch 'ticket/next/6117' into next
Diffstat (limited to 'spec/unit/network/http/api')
| -rwxr-xr-x | spec/unit/network/http/api/v1_spec.rb | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/spec/unit/network/http/api/v1_spec.rb b/spec/unit/network/http/api/v1_spec.rb index 3da8cbfae..d16ff122a 100755 --- a/spec/unit/network/http/api/v1_spec.rb +++ b/spec/unit/network/http/api/v1_spec.rb @@ -68,6 +68,10 @@ describe Puppet::Network::HTTP::API::V1 do @tester.uri2indirection("GET", "/env/foo/bar", {})[1].should == :find end + it "should choose 'find' as the indirection method if the http method is a POST and the indirection name is singular" do + @tester.uri2indirection("POST", "/env/foo/bar", {})[1].should == :find + end + it "should choose 'head' as the indirection method if the http method is a HEAD and the indirection name is singular" do @tester.uri2indirection("HEAD", "/env/foo/bar", {})[1].should == :head end @@ -164,4 +168,26 @@ describe Puppet::Network::HTTP::API::V1 do end end + describe "when converting a request into a URI with body" do + before :each do + @request = Puppet::Indirector::Request.new(:foo, :find, "with spaces", :foo => :bar, :environment => "myenv") + end + + it "should use the environment as the first field of the URI" do + @tester.request_to_uri_and_body(@request).first.split("/")[1].should == "myenv" + end + + it "should use the indirection as the second field of the URI" do + @tester.request_to_uri_and_body(@request).first.split("/")[2].should == "foo" + end + + it "should use the escaped key as the remainder of the URI" do + escaped = URI.escape("with spaces") + @tester.request_to_uri_and_body(@request).first.split("/")[3].sub(/\?.+/, '').should == escaped + end + + it "should return the URI and body separately" do + @tester.request_to_uri_and_body(@request).should == ["/myenv/foo/with%20spaces", "foo=bar"] + end + end end |
