#390 new
Jarl Friis

Webrat does not pass empty form file fields correctly to Rails

Reported by Jarl Friis | August 9th, 2010 @ 09:44 AM

When a page contains a file field and no file is uploaded, then a parameter is generated anyway. This was also the problem with rack testing some time ago (see http://rack.lighthouseapp.com/projects/22435/tickets/37).

Here is a minimal patch that solves the problem for webrat (tests should of course be made

--- /var/lib/gems/1.8/gems/webrat-0.7.1/lib/webrat/core/elements/form.rb.org    2010-05-26 21:11:16.978887686 +0200
+++ /var/lib/gems/1.8/gems/webrat-0.7.1/lib/webrat/core/elements/form.rb        2010-05-26 21:39:40.728106794 +0200
@@ -47,6 +47,7 @@

       fields.each do |field|
         next if field.to_query_string.nil?
+        next if field.is_a?(FileField) && field.test_uploaded_file.blank?
         replaces.merge!({field.digest_value => field.test_uploaded_file}) if field.is_a?(FileField)
         query_string << field.to_query_string


Comments and changes to this ticket

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile ยป

Ruby Acceptance Testing for Web applications.

Shared Ticket Bins

People watching this ticket

Referenced by