require File.dirname(__FILE__) + '/../test/test_helper' # Test that helpers from ActionView::Helpers::FormHelper are properly escaped. class FormHelperTest < Test::Unit::TestCase def setup @options = { :locals => { :@foo => stub(:bar => "f&b") } } end def test_check_box assert_render({ %(<%= check_box :foo, :bar %>) => %( ) }, @options) end def test_fields_for assert_render({ %(<% fields_for @foo.bar do |fields| %>Field: <%= fields.check_box :field %><% end %>) => %( Field: ) }, @options) end def test_file_field assert_render({ %(<%= file_field :foo, :bar, :class => "f&b" %>) => %( ) }, @options) end def test_form_for assert_render({ %(<% form_for :foo do |f| %>Bar: <%= f.text_field :bar %><% end %>) => %(
) }, @options) end def test_hidden_field assert_render({ %(<%= hidden_field :foo, :bar %>) => %( ) }, @options) end def test_label assert_render({ %(<%= label :foo, :bar, 'f&b' %>) => %() }, @options) end def test_password_field assert_render({ %(<%= password_field :foo, :bar %>) => %( ) }, @options) end def test_radio_button assert_render({ %(<%= radio_button :foo, :bar, 'f&b' %>) => %( ) }, @options) end def test_text_area assert_render({ %(<%= text_area :foo, :bar %>) => %( ) }, @options) end def test_text_field assert_render({ %(<%= text_field :foo, :bar %>) => %( ) }, @options) end end