diff --git a/lib/webrat/core/elements/form.rb b/lib/webrat/core/elements/form.rb index 1a9b5e6..5ab345c 100644 --- a/lib/webrat/core/elements/form.rb +++ b/lib/webrat/core/elements/form.rb @@ -73,7 +73,7 @@ module Webrat when Hash value = replace_param_value(value, oval, nval) when Array - value = value.map { |o| o == oval ? nval : o } + value = value.map { |o| o == oval ? nval : ( o.is_a?(Hash) ? replace_param_value(o, oval, nval) : o) } when oval value = nval end diff --git a/spec/private/rails/attaches_file_spec.rb b/spec/private/rails/attaches_file_spec.rb index e044db0..8d1445c 100644 --- a/spec/private/rails/attaches_file_spec.rb +++ b/spec/private/rails/attaches_file_spec.rb @@ -78,4 +78,19 @@ describe "attach_file" do attach_file "Picture", @filename, "image/png" click_button end + + it "should support nested attributes" do + with_html <<-HTML + +
+ + HTML + webrat_session.should_receive(:post).with("/albums", { "album" => { "photos_attributes" => [{"image" => @uploaded_file}] } }) + attach_file "Photo", @filename + click_button + end end