Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Integration tests (including Webrat) using multiple checkboxes and file attachments will fail (in Rails 2.3.2). This fixes them.
Dir["#{Rails.root}/lib/hotfixes/*.rb"].each do |hotfix|
load hotfix
end
if Rails.env == "test"
require "action_controller/integration"
class ActionController::Integration::Session
private
def multipart_requestify(params, first=true)
params.inject([]) do |collection, (key, value)|
k = first ? CGI.escape(key.to_s) : "[#{CGI.escape(key.to_s)}]"
case value
when Hash
multipart_requestify(value, false).each do |subkey, subvalue|
collection << [k + subkey, subvalue]
end
when Array
value.each do |subvalue|
collection << [k + "[]", subvalue]
end
else
collection << [k, value]
end
collection
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment