Skip to content

Instantly share code, notes, and snippets.

@threedaymonk
Created July 28, 2009 10:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save threedaymonk/157056 to your computer and use it in GitHub Desktop.
Save threedaymonk/157056 to your computer and use it in GitHub Desktop.
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