Created
July 28, 2009 10:00
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Dir["#{Rails.root}/lib/hotfixes/*.rb"].each do |hotfix| | |
load hotfix | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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