From ff42db076f5f2ff046ea8ce7cd4230571319a629 Mon Sep 17 00:00:00 2001 From: Noah Davis Date: Sat, 11 Apr 2009 13:18:09 -0400 Subject: [PATCH] Select fields with duplicate selected options sent an incorrect value --- History.txt | 1 + lib/webrat/core/elements/field.rb | 2 +- spec/public/select_spec.rb | 15 +++++++++++++++ 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/History.txt b/History.txt index a295774..6ff4932 100644 --- a/History.txt +++ b/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 diff --git a/lib/webrat/core/elements/field.rb b/lib/webrat/core/elements/field.rb index 2752935..7eecc94 100644 --- a/lib/webrat/core/elements/field.rb +++ b/lib/webrat/core/elements/field.rb @@ -396,7 +396,7 @@ module Webrat selected_options.map do |option| return "" if option.nil? Webrat::XML.attribute(option, "value") || Webrat::XML.inner_html(option) - end + end.uniq end end diff --git a/spec/public/select_spec.rb b/spec/public/select_spec.rb index eda9ad3..e5a5172 100644 --- a/spec/public/select_spec.rb +++ b/spec/public/select_spec.rb @@ -243,4 +243,19 @@ describe "select" do pending("needs bug fix", &spec) end end + + it "should submit duplicates selected options as a single value" do + with_html <<-HTML + +
+ + +
+ + HTML + + webrat_session.should_receive(:post).with("/login", "clothes" => "pants") + click_button + end + end