#198 awaiting-patch
Sven Fuchs

Webrat confused about overly nested params?

Reported by Sven Fuchs | March 15th, 2009 @ 11:28 AM

Not sure, but in Rails I get:


<form>
  <select type="text" name="filters[body][][scope]"><option name="contains">contains</option></select>
  <input type="text" name="filters[body][][query]" value="foo">
  <select type="text" name="filters[body][][scope]"><option name="starts_with">starts_with</option></select>
  <input type="text" name="filters[body][][query]" value="bar">
  <input type="submit" id="submit" value="submit">
</form>
 
# when send through browser (safari, firefox) params[:filter] is:
{"body"=>[{"scope"=>"contains", "query"=>"foo"}, {"scope"=>"starts_with", "query"=>"bar"}]}
 
# when send through webrat form submit params[:filter] is:
{"body"=>[{"query"=>"foo"}, {"scope"=>"contains", "query"=>"bar"}, {"scope"=>"starts_with"}]}

Comments and changes to this ticket

  • Sean Cribbs

    Sean Cribbs March 26th, 2009 @ 11:45 PM

    +1

    I am also experiencing this problem. I'm not going to quote view code because it's complicated, but here's what I get submitted when testing Radiant's page-editing UI with Cucumber/Webrat:

    @@@"parts"=>[{"name"=>"body"}, {"name"=>"extended"}, {"content"=>"Under Construction"}, {"content"=>"foobar"}, {"filter_id"=>""}, {"filter_id"=>""}]@@@

    Here's what it should look like: @@@parts"=>[{"name"=>"body", "content"=>"Under Construction", "filter_id"=>""}, {"name"=>"extended", "content"=>"foobar", "filter_id"=>""}]@@@

  • Sean Cribbs

    Sean Cribbs March 27th, 2009 @ 07:36 AM

    It seems that the problem stems from the fact that each field is converted to params individually, rather than the form as a whole. Perhaps we could extract the code that parses the parameters and generalize it so it can be used in both places? No sense in duplicating what Rails and Merb already do.

  • Sean Cribbs

    Sean Cribbs March 27th, 2009 @ 02:22 PM

    • Tag set to click_button, patch

    Patch available: http://github.com/seancribbs/web... (pull-request sent)

  • Sean Cribbs

    Sean Cribbs March 27th, 2009 @ 03:41 PM

    Ok, that seemed to work for some simple nested params, but things are still being merged out of order - I've added a failing spec to the suite.

  • Sean Cribbs

    Sean Cribbs April 9th, 2009 @ 07:26 PM

    Resolved the failing spec. Essentially, Webrat::Field::xpath_search specified a sequence of XPath expressions that would collect all the fields, but they would be grouped by type, not in document-order. By using a union expression, elements come back in the proper order.

    Please see: http://github.com/seancribbs/web...

  • Clemens Kofler

    Clemens Kofler April 24th, 2009 @ 07:57 AM

    • Tag changed from click_button, patch to attach_file, bug, click_button, nested, params, patch

    Something similar happens with a pretty simple nesting:

    
    <input type="file" name="assets[][data]" />
    <input type="text" name="assets[][title]" />
    <input type="text" name="assets[][tag_list]" />
    

    Browser: params[:assets] # => [{:data => 'some rack stuff', :title => 'whatever', :tag_list => 'what ever'}]

    Webrat: params[:assets] # => ['path to file', {:title => 'whatever', :tag_list => 'what ever'}]

  • gaffo

    gaffo May 10th, 2009 @ 09:58 PM

    • Tag changed from attach_file, bug, click_button, nested, params, patch to attach_file, bug, click_button, nested, params, patch, verify
    • State changed from “new” to “awaiting-merge”

    So one thing I noticed is that you are short closing the inputs on the initial example. I'm hoping that's not the bug.

    On another note, the patch seems sane so we'll take a look at it. There are quite a few "new" tickets that we're trying to clear out so I'm trying to triage all of them first before I start pulling in and applying patches.

    so this one is still needed to verify but the patches look good and exist.

  • shawn (at vegantech)

    shawn (at vegantech) May 13th, 2009 @ 05:41 PM

    This patch doesn't fix the issue noted in the comment by Clemens Kofler.
    In /lib/webrat/core/elements/field.rb the FileField has a call to replace_param_value(super, @value, test_uploaded_file)
    in the same file.

  • gaffo

    gaffo May 14th, 2009 @ 03:59 AM

    • State changed from “awaiting-merge” to “awaiting-patch”

    Seems to be still not resolved

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile ยป

Ruby Acceptance Testing for Web applications.

Shared Ticket Bins

Pages