Added Net::HTTPCreated support.
This commit is contained in:
parent
15577498b0
commit
4cdeef2e54
2 changed files with 15 additions and 3 deletions
|
@ -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}'"
|
||||
|
|
|
@ -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"/)
|
||||
|
|
Loading…
Reference in a new issue