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

Ticket #6908: text_field_helper_ignores_redefined_method.diff

File text_field_helper_ignores_redefined_method.diff, 1.3 kB (added by ThiagoArrais, 2 years ago)
  • actionpack/test/template/form_helper_test.rb

    old new  
    7676    assert_equal expected, text_field(object_name, "title") 
    7777    assert_equal object_name, "post[]" 
    7878  end 
     79   
     80  def test_text_field_uses_redefined_method 
     81    def @post.title; 'Hello, Rails world!'; end 
     82    assert_equal 'Hello, Rails world!', @post.title 
     83    assert_dom_equal( 
     84      '<input id="post_title" name="post[title]" size="30" type="text" value="Hello, Rails world!" />', text_field("post", "title") 
     85    ) 
     86  end 
    7987 
    8088  def test_check_box 
    8189    assert_dom_equal( 
  • actionpack/lib/action_view/helpers/form_helper.rb

    old new  
    256256          options.delete("size") 
    257257        end 
    258258        options["type"] = field_type 
    259         options["value"] ||= value_before_type_cast(object) unless field_type == "file" 
     259        options["value"] ||= value(object) unless field_type == "file" 
    260260        add_default_name_and_id(options) 
    261261        tag("input", options) 
    262262      end