Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

There was a problem

You must be a member of this account.

This project is archived and is in readonly mode.

fix snowman test helper to include _method only on non-GET or non-POST

#5753

Writing a test for a search_field related bug recently (5730), turned out to be slightly harder than usual since the expected resulted included a _method = 'get' within the snowman method.

I've included a patch to ensure that the _method only outputs for non-GET or non-POST queries. (i thought perhaps it better to check non-GET and non-POST rather than PUT or DELETE since in the future perhaps we might support other verbs (RESTfulie?) in the snowman.

I've also modified my test to actually work as a "method" get, since it was a search form.

Basically this patch fixes the test helpers to ensure "whole_form" and "snowman" can be used correctly in tests.

Reported by Aditya Sanghi · October 3rd, 2010 @ 08:36 PM

State: resolved
Milestone: none
Assigned to: José Valim José Valim
Importance: Low

Activity

  1. Aditya Sanghi
  2. Aditya Sanghi
    Aditya Sanghi
    • Title changed from fix snowman test helper to include _method only on put or delete to fix snowman test helper to include _method only on non-GET or non-POST

    October 3rd, 2010 @ 08:40 PM

  3. Aditya Sanghi
    Aditya Sanghi
    • Title changed from fix snowman test helper to include _method only on non-GET or non-POST to [PATCH] fix snowman test helper to include _method only on non-GET or non-POST

    October 3rd, 2010 @ 09:23 PM

  4. Aditya Sanghi
    Aditya Sanghi
    • Assigned user set to José Valim
    • Tag changed from tests actionpack, 3.x, actionview to tests actionpack, 3.x, actionview, patch

    To be clearer, when writing tests, using whole_form and snowman helpers methods led to incorrect expected text. Those helpers do not handle "get" method forms very well which is what this patch fixes.

    <%= form_for(@post, :url => search_posts_path, :html => {:method => :get}) do |f| %>

    {mkd-extraction-27744e020310fe464731a5d317065098}

    <% end %>

    was resulting in the snowman function putting a hidden parameter for "_method" with value = "get" which is wrong. The form_text was also hard-coded to always put the method in the form as "post".

    October 4th, 2010 @ 02:32 PM

  5. Aditya Sanghi
    Aditya Sanghi

    Is more information required for this ticket?

    October 7th, 2010 @ 08:23 AM

  6. José Valim
    José Valim
    • Importance changed from to Low

    It seems it does not. However be patient as I am a bit busy right now. I will apply it this or next week when I give another pass in LH applying tickets.

    October 7th, 2010 @ 08:29 AM

  7. Jeff Kreeftmeijer
    Jeff Kreeftmeijer
    • Title changed from [PATCH] fix snowman test helper to include _method only on non-GET or non-POST to fix snowman test helper to include _method only on non-GET or non-POST

    Using the "patch" tag instead of prefixing the ticket title with "[PATCH]" to make sure patched tickets end up in the open patches bin. :)

    October 11th, 2010 @ 08:16 PM

  8. Repository