diff options
Diffstat (limited to 'actionpack/test/template/form_tag_helper_test.rb')
-rw-r--r-- | actionpack/test/template/form_tag_helper_test.rb | 40 |
1 files changed, 25 insertions, 15 deletions
diff --git a/actionpack/test/template/form_tag_helper_test.rb b/actionpack/test/template/form_tag_helper_test.rb index 47b3605849..4e4102aec7 100644 --- a/actionpack/test/template/form_tag_helper_test.rb +++ b/actionpack/test/template/form_tag_helper_test.rb @@ -35,21 +35,23 @@ class FormTagHelperTest < ActionView::TestCase expected = %(<form action="http://www.example.com" method="post"><div style='margin:0;padding:0'><input type="hidden" name="_method" value="put" /></div>) assert_dom_equal expected, actual end - + def test_form_tag_with_method_delete actual = form_tag({}, { :method => :delete }) expected = %(<form action="http://www.example.com" method="post"><div style='margin:0;padding:0'><input type="hidden" name="_method" value="delete" /></div>) assert_dom_equal expected, actual end - def test_form_tag_with_block + def test_form_tag_with_block_in_erb + __in_erb_template = '' form_tag("http://example.com") { concat "Hello world!" } expected = %(<form action="http://example.com" method="post">Hello world!</form>) assert_dom_equal expected, output_buffer end - def test_form_tag_with_block_and_method + def test_form_tag_with_block_and_method_in_erb + __in_erb_template = '' form_tag("http://example.com", :method => :put) { concat "Hello world!" } expected = %(<form action="http://example.com" method="post"><div style='margin:0;padding:0'><input type="hidden" name="_method" value="put" /></div>Hello world!</form>) @@ -88,11 +90,11 @@ class FormTagHelperTest < ActionView::TestCase actual = radio_button_tag("gender", "m") + radio_button_tag("gender", "f") expected = %(<input id="gender_m" name="gender" type="radio" value="m" /><input id="gender_f" name="gender" type="radio" value="f" />) assert_dom_equal expected, actual - + actual = radio_button_tag("opinion", "-1") + radio_button_tag("opinion", "1") expected = %(<input id="opinion_-1" name="opinion" type="radio" value="-1" /><input id="opinion_1" name="opinion" type="radio" value="1" />) assert_dom_equal expected, actual - + actual = radio_button_tag("person[gender]", "m") expected = %(<input id="person_gender_m" name="person[gender]" type="radio" value="m" />) assert_dom_equal expected, actual @@ -103,13 +105,13 @@ class FormTagHelperTest < ActionView::TestCase expected = %(<select id="people" name="people"><option>david</option></select>) assert_dom_equal expected, actual end - + def test_select_tag_with_multiple actual = select_tag "colors", "<option>Red</option><option>Blue</option><option>Green</option>", :multiple => :true expected = %(<select id="colors" multiple="multiple" name="colors"><option>Red</option><option>Blue</option><option>Green</option></select>) assert_dom_equal expected, actual end - + def test_select_tag_disabled actual = select_tag "places", "<option>Home</option><option>Work</option><option>Pub</option>", :disabled => :true expected = %(<select id="places" disabled="disabled" name="places"><option>Home</option><option>Work</option><option>Pub</option></select>) @@ -145,37 +147,37 @@ class FormTagHelperTest < ActionView::TestCase expected = %(<input class="admin" id="title" name="title" type="text" value="Hello!" />) assert_dom_equal expected, actual end - + def test_text_field_tag_size_symbol actual = text_field_tag "title", "Hello!", :size => 75 expected = %(<input id="title" name="title" size="75" type="text" value="Hello!" />) assert_dom_equal expected, actual end - + def test_text_field_tag_size_string actual = text_field_tag "title", "Hello!", "size" => "75" expected = %(<input id="title" name="title" size="75" type="text" value="Hello!" />) assert_dom_equal expected, actual end - + def test_text_field_tag_maxlength_symbol actual = text_field_tag "title", "Hello!", :maxlength => 75 expected = %(<input id="title" name="title" maxlength="75" type="text" value="Hello!" />) assert_dom_equal expected, actual end - + def test_text_field_tag_maxlength_string actual = text_field_tag "title", "Hello!", "maxlength" => "75" expected = %(<input id="title" name="title" maxlength="75" type="text" value="Hello!" />) assert_dom_equal expected, actual end - + def test_text_field_disabled actual = text_field_tag "title", "Hello!", :disabled => :true expected = %(<input id="title" name="title" disabled="disabled" type="text" value="Hello!" />) assert_dom_equal expected, actual end - + def test_text_field_tag_with_multiple_options actual = text_field_tag "title", "Hello!", :size => 70, :maxlength => 80 expected = %(<input id="title" name="title" size="70" maxlength="80" type="text" value="Hello!" />) @@ -220,18 +222,26 @@ class FormTagHelperTest < ActionView::TestCase ) end + def test_submit_tag_with_no_onclick_options + assert_dom_equal( + %(<input name='commit' type='submit' value='Save' onclick="this.setAttribute('originalValue', this.value);this.disabled=true;this.value='Saving...';result = (this.form.onsubmit ? (this.form.onsubmit() ? this.form.submit() : false) : this.form.submit());if (result == false) { this.value = this.getAttribute('originalValue'); this.disabled = false };return result;" />), + submit_tag("Save", :disable_with => "Saving...") + ) + end + def test_submit_tag_with_confirmation assert_dom_equal( %(<input name='commit' type='submit' value='Save' onclick="return confirm('Are you sure?');"/>), submit_tag("Save", :confirm => "Are you sure?") ) end - + def test_pass assert_equal 1, 1 end - def test_field_set_tag + def test_field_set_tag_in_erb + __in_erb_template = '' field_set_tag("Your details") { concat "Hello world!" } expected = %(<fieldset><legend>Your details</legend>Hello world!</fieldset>) |