fixes #341 attach_file with nested attributes
This commit is contained in:
parent
15102bd60d
commit
c49e23d81d
@ -73,7 +73,7 @@ module Webrat
|
|||||||
when Hash
|
when Hash
|
||||||
value = replace_param_value(value, oval, nval)
|
value = replace_param_value(value, oval, nval)
|
||||||
when Array
|
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
|
when oval
|
||||||
value = nval
|
value = nval
|
||||||
end
|
end
|
||||||
|
@ -78,4 +78,19 @@ describe "attach_file" do
|
|||||||
attach_file "Picture", @filename, "image/png"
|
attach_file "Picture", @filename, "image/png"
|
||||||
click_button
|
click_button
|
||||||
end
|
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
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user