Select fields with duplicate selected options sent an incorrect value

This commit is contained in:
Noah Davis 2009-04-11 13:18:09 -04:00
parent 03914fd293
commit ff42db076f
3 changed files with 17 additions and 1 deletions

View File

@ -15,6 +15,7 @@
* Don't create a new instance of WWW::Mechanize for each request * Don't create a new instance of WWW::Mechanize for each request
(Mark Menard) (Mark Menard)
* Select fields with duplicate selected options sent an incorrect value (Noah Davis)
== 0.4.3 / 2009-03-17 == 0.4.3 / 2009-03-17

View File

@ -396,7 +396,7 @@ module Webrat
selected_options.map do |option| selected_options.map do |option|
return "" if option.nil? return "" if option.nil?
Webrat::XML.attribute(option, "value") || Webrat::XML.inner_html(option) Webrat::XML.attribute(option, "value") || Webrat::XML.inner_html(option)
end end.uniq
end end
end end

View File

@ -243,4 +243,19 @@ describe "select" do
pending("needs bug fix", &spec) pending("needs bug fix", &spec)
end end
end end
it "should submit duplicates selected options as a single value" do
with_html <<-HTML
<html>
<form method="post" action="/login">
<select name="clothes"><option value="pants" selected="selected">pants</option><option value="pants" selected="selected">pants</option></select>
<input type="submit" />
</form>
</html>
HTML
webrat_session.should_receive(:post).with("/login", "clothes" => "pants")
click_button
end
end end