Added Net::HTTPCreated support.

This commit is contained in:
Martin Edenhofer 2015-03-23 01:50:03 +01:00
parent 15577498b0
commit 4cdeef2e54
2 changed files with 15 additions and 3 deletions

View file

@ -314,6 +314,18 @@ returns
:success => true,
:code => response.code,
)
when Net::HTTPCreated
data = nil
if options[:json] && response.body
data = JSON.parse( response.body )
end
return Result.new(
:data => data,
:body => response.body,
:content_type => response['Content-Type'],
:success => true,
:code => response.code,
)
end
raise "Unable to process http call '#{response.inspect}'"

View file

@ -38,7 +38,7 @@ class UserAgentTest < ActiveSupport::TestCase
)
assert(result)
assert_equal(true, result.success?)
assert_equal('200', result.code)
assert_equal('201', result.code)
assert_equal(String, result.body.class)
assert(result.body =~ /"post"/)
assert(result.body =~ /"some value"/)
@ -151,7 +151,7 @@ class UserAgentTest < ActiveSupport::TestCase
)
assert(result)
assert_equal(true, result.success?)
assert_equal('200', result.code)
assert_equal('201', result.code)
assert_equal(String, result.body.class)
assert(result.body =~ /"post"/)
assert(result.body =~ /"some value"/)
@ -468,7 +468,7 @@ class UserAgentTest < ActiveSupport::TestCase
)
assert(result)
assert_equal(true, result.success?)
assert_equal('200', result.code)
assert_equal('201', result.code)
assert_equal(String, result.body.class)
assert(result.body =~ /"content_type_requested"/)
assert(result.body =~ /"application\/json"/)