fix post method in mechanize adapter to handle data as array or hash
it fixes spec/integration/mechanize/sample_app.rb:20
This commit is contained in:
parent
c49123c772
commit
06bb72d24f
@ -22,13 +22,19 @@ module Webrat #:nodoc:
|
|||||||
|
|
||||||
def post(url, data, headers_argument_not_used = nil)
|
def post(url, data, headers_argument_not_used = nil)
|
||||||
post_data = data.inject({}) do |memo, param|
|
post_data = data.inject({}) do |memo, param|
|
||||||
case param.last
|
case param
|
||||||
when Hash
|
when Hash
|
||||||
param.last.each {|attribute, value| memo["#{param.first}[#{attribute}]"] = value }
|
param.each {|attribute, value| memo[attribute] = value }
|
||||||
else
|
memo
|
||||||
memo[param.first] = param.last
|
when Array
|
||||||
|
case param.last
|
||||||
|
when Hash
|
||||||
|
param.last.each {|attribute, value| memo["#{param.first}[#{attribute}]"] = value }
|
||||||
|
else
|
||||||
|
memo[param.first] = param.last
|
||||||
|
end
|
||||||
|
memo
|
||||||
end
|
end
|
||||||
memo
|
|
||||||
end
|
end
|
||||||
@response = mechanize.post(url, post_data)
|
@response = mechanize.post(url, post_data)
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user