Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Ticket #4735: form_helper_method_index_test_patch.3.diff

File form_helper_method_index_test_patch.3.diff, 2.3 kB (added by charles.dupont@vanderbilt.edu, 2 years ago)

Index option tests for all form_helper methods; now from a sane root dir. admin please condense these 3 attachments to just the most recent.

  • actionpack/test/template/form_helper_test.rb

    old new  
    118118  def test_radio_button_is_checked_with_integers 
    119119    assert_dom_equal('<input checked="checked" id="post_secret_1" name="post[secret]" type="radio" value="1" />', 
    120120      radio_button("post", "secret", "1") 
    121    
     121    
    122122  end 
    123123 
    124124  def test_text_area 
     
    203203      "<input checked=\"checked\" id=\"post_#{pid}_secret\" name=\"post[#{pid}][secret]\" type=\"checkbox\" value=\"1\" /><input name=\"post[#{pid}][secret]\" type=\"hidden\" value=\"0\" />", 
    204204      check_box("post[]", "secret") 
    205205    ) 
    206    assert_dom_equal( 
     206    assert_dom_equal( 
    207207"<input checked=\"checked\" id=\"post_#{pid}_title_hello_world\" name=\"post[#{pid}][title]\" type=\"radio\" value=\"Hello World\" />", 
    208208      radio_button("post[]", "title", "Hello World") 
    209209    ) 
     
    212212    ) 
    213213  end 
    214214 
     215  def test_explicit_index 
     216    index = "dont_guess" 
     217    assert_dom_equal( 
     218      "<input id=\"post_#{index}_title\" name=\"post[#{index}][title]\" size=\"30\" type=\"text\" value=\"Hello World\" />", 
     219      text_field("post","title", {"index"=>index}) 
     220    ) 
     221                      
     222    assert_dom_equal( 
     223      "<textarea cols=\"40\" id=\"post_#{index}_body\" name=\"post[#{index}][body]\" rows=\"20\">Back to the hill and over it again!</textarea>", 
     224      text_area("post", "body", {"index"=>index}) 
     225    ) 
     226    assert_dom_equal( 
     227      "<input checked=\"checked\" id=\"post_#{index}_secret\" name=\"post[#{index}][secret]\" type=\"checkbox\" value=\"1\" /><input name=\"post[#{index}][secret]\" type=\"hidden\" value=\"0\" />", 
     228      check_box("post", "secret", {"index"=>index}) 
     229    ) 
     230    assert_dom_equal( 
     231"<input checked=\"checked\" id=\"post_#{index}_title_hello_world\" name=\"post[#{index}][title]\" type=\"radio\" value=\"Hello World\" />", 
     232      radio_button("post", "title", "Hello World", {"index"=>index}) 
     233    ) 
     234    assert_dom_equal("<input id=\"post_#{index}_title_goodbye_world\" name=\"post[#{index}][title]\" type=\"radio\" value=\"Goodbye World\" />", 
     235      radio_button("post", "title", "Goodbye World", {"index"=>index}) 
     236    ) 
     237  end 
     238   
    215239  def test_form_for 
    216240    _erbout = '' 
    217241