diff options
| author | Luke Kanies <luke@madstop.com> | 2009-02-19 16:09:58 -0600 |
|---|---|---|
| committer | Luke Kanies <luke@madstop.com> | 2009-02-19 17:51:22 -0600 |
| commit | 262937ff6e505bbf86d15500279ff23398f9e1c8 (patch) | |
| tree | 66084a1e14ed86f19982b800f60d332c139c8a36 /spec/unit/network/http/handler.rb | |
| parent | b800bde30bd5a08f5e222725588062e2bca37a79 (diff) | |
| download | puppet-262937ff6e505bbf86d15500279ff23398f9e1c8.tar.gz puppet-262937ff6e505bbf86d15500279ff23398f9e1c8.tar.xz puppet-262937ff6e505bbf86d15500279ff23398f9e1c8.zip | |
Correctly handling URI escaping throughout the REST process
This means, at the least, that we can now serve files
via REST when they have spaces and other weird characters
in their names.
This involves a small change to many files.
Signed-off-by: Luke Kanies <luke@madstop.com>
Diffstat (limited to 'spec/unit/network/http/handler.rb')
| -rwxr-xr-x | spec/unit/network/http/handler.rb | 24 |
1 files changed, 20 insertions, 4 deletions
diff --git a/spec/unit/network/http/handler.rb b/spec/unit/network/http/handler.rb index ed0f25121..6f1a57b8b 100755 --- a/spec/unit/network/http/handler.rb +++ b/spec/unit/network/http/handler.rb @@ -229,12 +229,20 @@ describe Puppet::Network::HTTP::Handler do Puppet::Network::FormatHandler.stubs(:format).returns @format end - it "should fail to find model if key is not specified" do + it "should fail if the key is not specified" do @handler.stubs(:request_key).returns(nil) lambda { @handler.do_find(@request, @response) }.should raise_error(ArgumentError) end + it "should use the escaped request key" do + @handler.stubs(:request_key).returns URI.escape("my key") + @model_class.expects(:find).with do |key, args| + key == "my key" + end.returns @result + @handler.do_find(@request, @response) + end + it "should use a common method for determining the request parameters" do @handler.stubs(:params).returns(:foo => :baz, :bar => :xyzzy) @model_class.expects(:find).with do |key, args| @@ -336,9 +344,9 @@ describe Puppet::Network::HTTP::Handler do @handler.do_search(@request, @response) end - it "should use a request key if one is provided" do - @handler.expects(:request_key).with(@request).returns "foo" - @model_class.expects(:search).with { |key, args| key == "foo" }.returns @result + it "should use an escaped request key if one is provided" do + @handler.expects(:request_key).with(@request).returns URI.escape("foo bar") + @model_class.expects(:search).with { |key, args| key == "foo bar" }.returns @result @handler.do_search(@request, @response) end @@ -402,6 +410,14 @@ describe Puppet::Network::HTTP::Handler do lambda { @handler.do_destroy(@request, @response) }.should raise_error(ArgumentError) end + it "should use the escaped request key to destroy the instance in the model" do + @handler.expects(:request_key).returns URI.escape("foo bar") + @model_class.expects(:destroy).with do |key, args| + key == "foo bar" + end + @handler.do_destroy(@request, @response) + end + it "should use a common method for determining the request parameters" do @handler.stubs(:params).returns(:foo => :baz, :bar => :xyzzy) @model_class.expects(:destroy).with do |key, args| |
