Skip to content
This repository has been archived by the owner on Nov 19, 2021. It is now read-only.

Commit

Permalink
fixes #341 attach_file with nested attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
zevarito committed Apr 5, 2010
1 parent 15102bd commit c49e23d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/webrat/core/elements/form.rb
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ def self.replace_param_value(params, oval, nval)
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
Expand Down
15 changes: 15 additions & 0 deletions spec/private/rails/attaches_file_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -78,4 +78,19 @@
attach_file "Picture", @filename, "image/png"
click_button
end

it "should support nested attributes" do
with_html <<-HTML
<html>
<form method="post" action="/albums">
<label for="photo_file1">Photo</label>
<input type="file" id="photo_file1" name="album[photos_attributes][][image]" />
<input type="submit" />
</form>
</html>
HTML
webrat_session.should_receive(:post).with("/albums", { "album" => { "photos_attributes" => [{"image" => @uploaded_file}] } })
attach_file "Photo", @filename
click_button
end
end

0 comments on commit c49e23d

Please sign in to comment.