Serialize empty text field values just like browsers
This commit is contained in:
parent
8dad835e86
commit
db3fe608ea
|
@ -1,5 +1,6 @@
|
|||
== Trunk
|
||||
|
||||
* Serialize empty text field values just like browsers (Patch from Kamal Fariz Mahyuddi)
|
||||
* Added clicks_link_within(selector, link_text), allowing restricting link search
|
||||
to within a given css selector (Path from Luke Melia)
|
||||
* Change clicks_link to find the shortest matching link (Patch from Luke Melia)
|
||||
|
|
|
@ -399,8 +399,8 @@ module ActionController
|
|||
end
|
||||
|
||||
def add_default_params_from_inputs_for(form) # :nodoc:
|
||||
((form / "input[@type='text']") + (form / "input[@type='hidden']")).each do |input|
|
||||
next if input.attributes["value"].blank?
|
||||
(form / "input").each do |input|
|
||||
next unless %w[text hidden].include?(input.attributes["type"])
|
||||
add_form_data(input, input.attributes["value"])
|
||||
end
|
||||
end
|
||||
|
|
|
@ -272,4 +272,15 @@ class ClicksButtonTest < Test::Unit::TestCase
|
|||
@session.expects(:post_via_redirect).with("/login", "contestant" => {"scores" => {'1' => '2', '3' => '4'}})
|
||||
@session.clicks_button
|
||||
end
|
||||
|
||||
def test_should_send_default_empty_text_field_values
|
||||
@response.stubs(:body).returns(<<-EOS)
|
||||
<form method="get" action="/login">
|
||||
<input id="user_email" name="user[email]" value="" type="text" />
|
||||
<input type="submit" />
|
||||
</form>
|
||||
EOS
|
||||
@session.expects(:get_via_redirect).with("/login", "user" => {"email" => ""})
|
||||
@session.clicks_button
|
||||
end
|
||||
end
|
||||
|
|
|
@ -54,7 +54,7 @@ class FillsInTest < Test::Unit::TestCase
|
|||
</form>
|
||||
EOS
|
||||
|
||||
@session.expects(:post_via_redirect).with("/login", "user" => {"mail2" => "value"})
|
||||
@session.expects(:post_via_redirect).with("/login", "user" => {"mail1" => "", "mail2" => "value"})
|
||||
@session.fills_in "Some", :with => "value"
|
||||
@session.clicks_button
|
||||
end
|
||||
|
@ -70,7 +70,7 @@ class FillsInTest < Test::Unit::TestCase
|
|||
</form>
|
||||
EOS
|
||||
|
||||
@session.expects(:post_via_redirect).with("/login", "user" => {"mail1" => "value"})
|
||||
@session.expects(:post_via_redirect).with("/login", "user" => {"mail1" => "value", "mail2" => ""})
|
||||
@session.fills_in "Some mail", :with => "value"
|
||||
@session.clicks_button
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue