Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Fixing a problem when submitting form with blank values #47

Open
wants to merge 1 commit into from

2 participants

SHIMADA Koji cynipe
SHIMADA Koji

I've fixed a problem when submitting form with blank values.

cynipe

++

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Dec 19, 2010
  1. SHIMADA Koji
This page is out of date. Refresh to see the latest.
2  lib/webrat/core/elements/form.rb
View
@@ -110,7 +110,7 @@ def self.query_string_to_params(query_string)
when :rack, :sinatra
Rack::Utils.parse_nested_query(query_string)
else
- query_string.split('&').map {|query| { query.split('=').first => query.split('=').last }}
+ query_string.split('&').map {|query| Hash[*query.split('=', 2)] }
end
end
2  spec/integration/mechanize/sample_app.rb
View
@@ -30,6 +30,6 @@ class SampleApp < Sinatra::Default
end
put "/form" do
- "Welcome #{params[:email]}"
+ "Welcome '#{params[:email]}'"
end
end
10 spec/integration/mechanize/spec/mechanize_spec.rb
View
@@ -18,7 +18,15 @@
fill_in "Email", :with => "albert@example.com"
response = click_button "Add"
- response.should contain("Welcome albert@example.com")
+ response.should contain("Welcome 'albert@example.com'")
+ end
+
+ it "should submit forms with field whose value is blank" do
+ visit "http://localhost:9292/form"
+ fill_in "Email", :with => ""
+ response = click_button "Add"
+
+ response.should contain("Welcome ''")
end
it "should not follow external redirects" do
Something went wrong with that request. Please try again.