diff --git a/lib/webrat/session.rb b/lib/webrat/session.rb index 0a8168f..ae93209 100644 --- a/lib/webrat/session.rb +++ b/lib/webrat/session.rb @@ -301,10 +301,10 @@ module ActionController form_data[form_number] ||= {} data.each do |key, value| - if form_data[form_number][key].is_a?(Hash) - merge(form_data[form_number][key], value) - else - form_data[form_number][key] = value + case form_data[form_number][key] + when Hash; then merge(form_data[form_number][key], value) + when Array; then form_data[form_number][key] = (form_data[form_number][key] | value).sort + else form_data[form_number][key] = value end end end diff --git a/test/clicks_button_test.rb b/test/clicks_button_test.rb index ec529ff..c8d5274 100644 --- a/test/clicks_button_test.rb +++ b/test/clicks_button_test.rb @@ -196,6 +196,20 @@ class ClicksButtonTest < Test::Unit::TestCase @session.expects(:get_via_redirect).with("/login", "user" => {"tos" => "1"}) @session.clicks_button end + + def test_should_send_default_collection_fields + @response.stubs(:body).returns(<<-EOS) +
+ EOS + @session.expects(:post_via_redirect).with("/login", "options" => ["burger", "dessert", "fries", "soda"]) + @session.clicks_button + end def test_should_not_send_default_unchecked_fields @response.stubs(:body).returns(<<-EOS)