fa881a88c8
* Basically Field#to_param was replaced for Field#to_query_string and some methods related to build params were moved to Form class. Before this commit the params hash was made by parsing each element querystring to param and then merge, now we build the whole querystring first and then parse it to get params with Rack or Rails depending of the configure mode.
52 lines
1.8 KiB
Ruby
52 lines
1.8 KiB
Ruby
require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
|
|
|
|
describe "Multiple nested params" do
|
|
it "should be corretly posted" do
|
|
Webrat.configuration.mode = :rails
|
|
|
|
with_html <<-HTML
|
|
<html>
|
|
<form method="post" action="/family">
|
|
<div class="couple">
|
|
<div class="parent">
|
|
<select name="user[family][parents][0][][gender]">
|
|
<option selected="selected" value="Mother">Mother</option>
|
|
<option value="Father">Father</option>
|
|
</select>
|
|
<input type="text" value="Alice" name="user[family][parents][0][][name]" />
|
|
</div>
|
|
<div class="parent">
|
|
<select name="user[family][parents][0][][gender]">
|
|
<option value="Mother">Mother</option>
|
|
<option selected="selected" value="Father">Father</option>
|
|
</select>
|
|
<input type="text" value="Michael" name="user[family][parents][0][][name]" />
|
|
</div>
|
|
</div>
|
|
<div class="couple">
|
|
<div class="parent">
|
|
<select name="user[family][parents][1][][gender]">
|
|
<option selected="selected" value="Mother">Mother</option>
|
|
<option value="Father">Father</option>
|
|
</select>
|
|
<input type="text" value="Jenny" name="user[family][parents][1][][name]" />
|
|
</div>
|
|
</div>
|
|
<input type="submit" />
|
|
</form>
|
|
</html>
|
|
HTML
|
|
|
|
params = { "user" => { "family" => { "parents" => {
|
|
"0" => [ {"name" => "Alice", "gender"=>"Mother"}, {"name" => "Michael", "gender"=>"Father"} ],
|
|
"1" => [ {"name" => "Jenny", "gender"=>"Mother"} ]
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
webrat_session.should_receive(:post).with("/family", params)
|
|
click_button
|
|
end
|
|
end
|