Browse files

Select fields with duplicate selected options sent an incorrect value

  • Loading branch information...
1 parent 03914fd commit ff42db076f5f2ff046ea8ce7cd4230571319a629 @noahd1 noahd1 committed Apr 11, 2009
Showing with 17 additions and 1 deletion.
  1. +1 −0 History.txt
  2. +1 −1 lib/webrat/core/elements/field.rb
  3. +15 −0 spec/public/select_spec.rb
View
1 History.txt
@@ -15,6 +15,7 @@
* Don't create a new instance of WWW::Mechanize for each request
(Mark Menard)
+ * Select fields with duplicate selected options sent an incorrect value (Noah Davis)
== 0.4.3 / 2009-03-17
View
2 lib/webrat/core/elements/field.rb
@@ -396,7 +396,7 @@ def default_value
selected_options.map do |option|
return "" if option.nil?
Webrat::XML.attribute(option, "value") || Webrat::XML.inner_html(option)
- end
+ end.uniq
end
end
View
15 spec/public/select_spec.rb
@@ -243,4 +243,19 @@
pending("needs bug fix", &spec)
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

0 comments on commit ff42db0

Please sign in to comment.