class FormTagHelperTest
Constants
- VALID_HTML_ID
Public Instance Methods
form_text(action = "http://www.example.com", options = {})
click to toggle source
# File actionview/test/template/form_tag_helper_test.rb, line 40 def form_text(action = "http://www.example.com", options = {}) remote, enctype, html_class, id, method = options.values_at(:remote, :enctype, :html_class, :id, :method) method = method.to_s == "get" ? "get" : "post" txt = %{<form accept-charset="UTF-8" action="#{action}"}.dup txt << %{ enctype="multipart/form-data"} if enctype txt << %{ data-remote="true"} if remote txt << %{ class="#{html_class}"} if html_class txt << %{ id="#{id}"} if id txt << %{ method="#{method}">} end
protect_against_forgery?()
click to toggle source
# File actionview/test/template/form_tag_helper_test.rb, line 776 def protect_against_forgery? false end
setup()
click to toggle source
Calls superclass method
# File actionview/test/template/form_tag_helper_test.rb, line 20 def setup super @controller = BasicController.new end
test_boolean_options()
click to toggle source
# File actionview/test/template/form_tag_helper_test.rb, line 477 def test_boolean_options assert_dom_equal %(<input checked="checked" disabled="disabled" id="admin" name="admin" readonly="readonly" type="checkbox" value="1" />), check_box_tag("admin", 1, true, "disabled" => true, :readonly => "yes") assert_dom_equal %(<input checked="checked" id="admin" name="admin" type="checkbox" value="1" />), check_box_tag("admin", 1, true, disabled: false, readonly: nil) assert_dom_equal %(<input type="checkbox" />), tag(:input, type: "checkbox", checked: false) assert_dom_equal %(<select id="people" multiple="multiple" name="people[]"><option>david</option></select>), select_tag("people", raw("<option>david</option>"), multiple: true) assert_dom_equal %(<select id="people_" multiple="multiple" name="people[]"><option>david</option></select>), select_tag("people[]", raw("<option>david</option>"), multiple: true) assert_dom_equal %(<select id="people" name="people"><option>david</option></select>), select_tag("people", raw("<option>david</option>"), multiple: nil) end
test_check_box_tag()
click to toggle source
# File actionview/test/template/form_tag_helper_test.rb, line 73 def test_check_box_tag actual = check_box_tag "admin" expected = %(<input id="admin" name="admin" type="checkbox" value="1" />) assert_dom_equal expected, actual end
test_check_box_tag_default_checked()
click to toggle source
# File actionview/test/template/form_tag_helper_test.rb, line 85 def test_check_box_tag_default_checked actual = check_box_tag "admin", "1", true expected = %(<input id="admin" checked="checked" name="admin" type="checkbox" value="1" />) assert_dom_equal expected, actual end
test_check_box_tag_disabled()
click to toggle source
# File actionview/test/template/form_tag_helper_test.rb, line 79 def test_check_box_tag_disabled actual = check_box_tag "admin", "1", false, disabled: true expected = %(<input id="admin" disabled="disabled" name="admin" type="checkbox" value="1" />) assert_dom_equal expected, actual end
test_check_box_tag_id_sanitized()
click to toggle source
# File actionview/test/template/form_tag_helper_test.rb, line 91 def test_check_box_tag_id_sanitized label_elem = root_elem(check_box_tag("project[2][admin]")) assert_match VALID_HTML_ID, label_elem["id"] end
test_color_field_tag()
click to toggle source
# File actionview/test/template/form_tag_helper_test.rb, line 649 def test_color_field_tag expected = %{<input id="car" name="car" type="color" />} assert_dom_equal(expected, color_field_tag("car")) end
test_date_field_tag()
click to toggle source
# File actionview/test/template/form_tag_helper_test.rb, line 664 def test_date_field_tag expected = %{<input id="cell" name="cell" type="date" />} assert_dom_equal(expected, date_field_tag("cell")) end
test_datetime_field_tag()
click to toggle source
# File actionview/test/template/form_tag_helper_test.rb, line 674 def test_datetime_field_tag expected = %{<input id="appointment" name="appointment" type="datetime-local" />} assert_dom_equal(expected, datetime_field_tag("appointment")) end
test_datetime_local_field_tag()
click to toggle source
# File actionview/test/template/form_tag_helper_test.rb, line 679 def test_datetime_local_field_tag expected = %{<input id="appointment" name="appointment" type="datetime-local" />} assert_dom_equal(expected, datetime_local_field_tag("appointment")) end
test_email_field_tag()
click to toggle source
# File actionview/test/template/form_tag_helper_test.rb, line 699 def test_email_field_tag expected = %{<input id="address" name="address" type="email" />} assert_dom_equal(expected, email_field_tag("address")) end
test_empty_submit_tag()
click to toggle source
# File actionview/test/template/form_tag_helper_test.rb, line 499 def test_empty_submit_tag assert_dom_equal( %(<input data-disable-with="Save" name='commit' type="submit" value="Save" />), submit_tag("Save") ) end
test_empty_submit_tag_with_opt_out()
click to toggle source
# File actionview/test/template/form_tag_helper_test.rb, line 506 def test_empty_submit_tag_with_opt_out ActionView::Base.automatically_disable_submit_tag = false assert_dom_equal( %(<input name='commit' type="submit" value="Save" />), submit_tag("Save") ) ensure ActionView::Base.automatically_disable_submit_tag = true end
test_field_set_tag_in_erb()
click to toggle source
# File actionview/test/template/form_tag_helper_test.rb, line 714 def test_field_set_tag_in_erb output_buffer = render_erb("<%= field_set_tag('Your details') do %>Hello world!<% end %>") expected = %(<fieldset><legend>Your details</legend>Hello world!</fieldset>) assert_dom_equal expected, output_buffer output_buffer = render_erb("<%= field_set_tag do %>Hello world!<% end %>") expected = %(<fieldset>Hello world!</fieldset>) assert_dom_equal expected, output_buffer output_buffer = render_erb("<%= field_set_tag('') do %>Hello world!<% end %>") expected = %(<fieldset>Hello world!</fieldset>) assert_dom_equal expected, output_buffer output_buffer = render_erb("<%= field_set_tag('', :class => 'format') do %>Hello world!<% end %>") expected = %(<fieldset class="format">Hello world!</fieldset>) assert_dom_equal expected, output_buffer output_buffer = render_erb("<%= field_set_tag %>") expected = %(<fieldset></fieldset>) assert_dom_equal expected, output_buffer output_buffer = render_erb("<%= field_set_tag('You legend!') %>") expected = %(<fieldset><legend>You legend!</legend></fieldset>) assert_dom_equal expected, output_buffer end
test_file_field_tag()
click to toggle source
# File actionview/test/template/form_tag_helper_test.rb, line 183 def test_file_field_tag assert_dom_equal "<input name=\"picsplz\" type=\"file\" id=\"picsplz\" />", file_field_tag("picsplz") end
test_file_field_tag_with_direct_upload_dont_mutate_arguments()
click to toggle source
# File actionview/test/template/form_tag_helper_test.rb, line 207 def test_file_field_tag_with_direct_upload_dont_mutate_arguments original_options = { class: "pix", direct_upload: true } assert_dom_equal( "<input name=\"picsplz\" type=\"file\" id=\"picsplz\" class=\"pix\"/>", file_field_tag("picsplz", original_options) ) assert_equal({ class: "pix", direct_upload: true }, original_options) end
test_file_field_tag_with_direct_upload_when_quails_direct_uploads_url_is_defined()
click to toggle source
# File actionview/test/template/form_tag_helper_test.rb, line 198 def test_file_field_tag_with_direct_upload_when_quails_direct_uploads_url_is_defined @controller = WithActiveStorageRoutesControllers.new assert_dom_equal( "<input name=\"picsplz\" type=\"file\" id=\"picsplz\" class=\"pix\" data-direct-upload-url=\"http://testtwo.host/quails/active_storage/direct_uploads\"/>", file_field_tag("picsplz", class: "pix", direct_upload: true) ) end
test_file_field_tag_with_direct_upload_when_quails_direct_uploads_url_is_not_defined()
click to toggle source
# File actionview/test/template/form_tag_helper_test.rb, line 191 def test_file_field_tag_with_direct_upload_when_quails_direct_uploads_url_is_not_defined assert_dom_equal( "<input name=\"picsplz\" type=\"file\" id=\"picsplz\" class=\"pix\"/>", file_field_tag("picsplz", class: "pix", direct_upload: true) ) end
test_file_field_tag_with_options()
click to toggle source
# File actionview/test/template/form_tag_helper_test.rb, line 187 def test_file_field_tag_with_options assert_dom_equal "<input name=\"picsplz\" type=\"file\" id=\"picsplz\" class=\"pix\"/>", file_field_tag("picsplz", class: "pix") end
test_form_tag()
click to toggle source
# File actionview/test/template/form_tag_helper_test.rb, line 96 def test_form_tag actual = form_tag expected = whole_form assert_dom_equal expected, actual end
test_form_tag_enforce_utf8_false()
click to toggle source
# File actionview/test/template/form_tag_helper_test.rb, line 148 def test_form_tag_enforce_utf8_false actual = form_tag({}, { enforce_utf8: false }) expected = whole_form("http://www.example.com", enforce_utf8: false) assert_dom_equal expected, actual assert actual.html_safe? end
test_form_tag_enforce_utf8_true()
click to toggle source
# File actionview/test/template/form_tag_helper_test.rb, line 141 def test_form_tag_enforce_utf8_true actual = form_tag({}, { enforce_utf8: true }) expected = whole_form("http://www.example.com", enforce_utf8: true) assert_dom_equal expected, actual assert actual.html_safe? end
test_form_tag_multipart()
click to toggle source
# File actionview/test/template/form_tag_helper_test.rb, line 102 def test_form_tag_multipart actual = form_tag({}, { "multipart" => true }) expected = whole_form("http://www.example.com", enctype: true) assert_dom_equal expected, actual end
test_form_tag_with_block_and_method_in_erb()
click to toggle source
# File actionview/test/template/form_tag_helper_test.rb, line 162 def test_form_tag_with_block_and_method_in_erb output_buffer = render_erb("<%= form_tag('http://www.example.com', :method => :put) do %>Hello world!<% end %>") expected = whole_form("http://www.example.com", method: "put") do "Hello world!" end assert_dom_equal expected, output_buffer end
test_form_tag_with_block_in_erb()
click to toggle source
# File actionview/test/template/form_tag_helper_test.rb, line 155 def test_form_tag_with_block_in_erb output_buffer = render_erb("<%= form_tag('http://www.example.com') do %>Hello world!<% end %>") expected = whole_form { "Hello world!" } assert_dom_equal expected, output_buffer end
test_form_tag_with_method_delete()
click to toggle source
# File actionview/test/template/form_tag_helper_test.rb, line 120 def test_form_tag_with_method_delete actual = form_tag({}, { method: :delete }) expected = whole_form("http://www.example.com", method: :delete) assert_dom_equal expected, actual end
test_form_tag_with_method_patch()
click to toggle source
# File actionview/test/template/form_tag_helper_test.rb, line 108 def test_form_tag_with_method_patch actual = form_tag({}, { method: :patch }) expected = whole_form("http://www.example.com", method: :patch) assert_dom_equal expected, actual end
test_form_tag_with_method_put()
click to toggle source
# File actionview/test/template/form_tag_helper_test.rb, line 114 def test_form_tag_with_method_put actual = form_tag({}, { method: :put }) expected = whole_form("http://www.example.com", method: :put) assert_dom_equal expected, actual end
test_form_tag_with_remote()
click to toggle source
# File actionview/test/template/form_tag_helper_test.rb, line 127 def test_form_tag_with_remote actual = form_tag({}, { remote: true }) expected = whole_form("http://www.example.com", remote: true) assert_dom_equal expected, actual end
test_form_tag_with_remote_false()
click to toggle source
# File actionview/test/template/form_tag_helper_test.rb, line 134 def test_form_tag_with_remote_false actual = form_tag({}, { remote: false }) expected = whole_form assert_dom_equal expected, actual end
test_image_label_tag_options_symbolize_keys_side_effects()
click to toggle source
# File actionview/test/template/form_tag_helper_test.rb, line 770 def test_image_label_tag_options_symbolize_keys_side_effects options = { option: "random_option" } label_tag "submit source", "title", options assert_equal({ option: "random_option" }, options) end
test_image_submit_tag_options_symbolize_keys_side_effects()
click to toggle source
# File actionview/test/template/form_tag_helper_test.rb, line 764 def test_image_submit_tag_options_symbolize_keys_side_effects options = { option: "random_option" } image_submit_tag "submit source", options assert_equal({ option: "random_option" }, options) end
test_image_submit_tag_with_confirmation()
click to toggle source
# File actionview/test/template/form_tag_helper_test.rb, line 642 def test_image_submit_tag_with_confirmation assert_dom_equal( %(<input type="image" src="/images/save.gif" data-confirm="Are you sure?" />), image_submit_tag("save.gif", data: { confirm: "Are you sure?" }) ) end
test_label_tag_class_string()
click to toggle source
# File actionview/test/template/form_tag_helper_test.rb, line 452 def test_label_tag_class_string actual = label_tag "title", "My Title", "class" => "small_label" expected = %(<label for="title" class="small_label">My Title</label>) assert_dom_equal expected, actual end
test_label_tag_id_sanitized()
click to toggle source
# File actionview/test/template/form_tag_helper_test.rb, line 458 def test_label_tag_id_sanitized label_elem = root_elem(label_tag("item[title]")) assert_match VALID_HTML_ID, label_elem["for"] end
test_label_tag_with_block()
click to toggle source
# File actionview/test/template/form_tag_helper_test.rb, line 463 def test_label_tag_with_block assert_dom_equal("<label>Blocked</label>", label_tag { "Blocked" }) end
test_label_tag_with_block_and_argument()
click to toggle source
# File actionview/test/template/form_tag_helper_test.rb, line 467 def test_label_tag_with_block_and_argument output = label_tag("clock") { "Grandfather" } assert_dom_equal('<label for="clock">Grandfather</label>', output) end
test_label_tag_with_block_and_argument_and_options()
click to toggle source
# File actionview/test/template/form_tag_helper_test.rb, line 472 def test_label_tag_with_block_and_argument_and_options output = label_tag("clock", id: "label_clock") { "Grandfather" } assert_dom_equal('<label for="clock" id="label_clock">Grandfather</label>', output) end
test_label_tag_with_symbol()
click to toggle source
# File actionview/test/template/form_tag_helper_test.rb, line 440 def test_label_tag_with_symbol actual = label_tag :title expected = %(<label for="title">Title</label>) assert_dom_equal expected, actual end
test_label_tag_with_text()
click to toggle source
# File actionview/test/template/form_tag_helper_test.rb, line 446 def test_label_tag_with_text actual = label_tag "title", "My Title" expected = %(<label for="title">My Title</label>) assert_dom_equal expected, actual end
test_label_tag_without_text()
click to toggle source
# File actionview/test/template/form_tag_helper_test.rb, line 434 def test_label_tag_without_text actual = label_tag "title" expected = %(<label for="title">Title</label>) assert_dom_equal expected, actual end
test_month_field_tag()
click to toggle source
# File actionview/test/template/form_tag_helper_test.rb, line 684 def test_month_field_tag expected = %{<input id="birthday" name="birthday" type="month" />} assert_dom_equal(expected, month_field_tag("birthday")) end
test_number_field_tag()
click to toggle source
# File actionview/test/template/form_tag_helper_test.rb, line 704 def test_number_field_tag expected = %{<input name="quantity" max="9" id="quantity" type="number" min="1" />} assert_dom_equal(expected, number_field_tag("quantity", nil, in: 1...10)) end
test_password_field_tag()
click to toggle source
# File actionview/test/template/form_tag_helper_test.rb, line 218 def test_password_field_tag actual = password_field_tag expected = %(<input id="password" name="password" type="password" />) assert_dom_equal expected, actual end
test_range_input_tag()
click to toggle source
# File actionview/test/template/form_tag_helper_test.rb, line 709 def test_range_input_tag expected = %{<input name="volume" step="0.1" max="11" id="volume" type="range" min="0" />} assert_dom_equal(expected, range_field_tag("volume", nil, in: 0..11, step: 0.1)) end
test_search_field_tag()
click to toggle source
# File actionview/test/template/form_tag_helper_test.rb, line 654 def test_search_field_tag expected = %{<input id="query" name="query" type="search" />} assert_dom_equal(expected, search_field_tag("query")) end
test_select_tag()
click to toggle source
# File actionview/test/template/form_tag_helper_test.rb, line 257 def test_select_tag actual = select_tag "people", raw("<option>david</option>") expected = %(<select id="people" name="people"><option>david</option></select>) assert_dom_equal expected, actual end
test_select_tag_disabled()
click to toggle source
# File actionview/test/template/form_tag_helper_test.rb, line 269 def test_select_tag_disabled actual = select_tag "places", raw("<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>) assert_dom_equal expected, actual end
test_select_tag_escapes_prompt()
click to toggle source
# File actionview/test/template/form_tag_helper_test.rb, line 304 def test_select_tag_escapes_prompt actual = select_tag "places", raw("<option>Home</option><option>Work</option><option>Pub</option>"), prompt: "<script>alert(1337)</script>" expected = %(<select id="places" name="places"><option value=""><script>alert(1337)</script></option><option>Home</option><option>Work</option><option>Pub</option></select>) assert_dom_equal expected, actual end
test_select_tag_id_sanitized()
click to toggle source
# File actionview/test/template/form_tag_helper_test.rb, line 275 def test_select_tag_id_sanitized input_elem = root_elem(select_tag("project[1]people", "<option>david</option>")) assert_match VALID_HTML_ID, input_elem["id"] end
test_select_tag_with_include_blank()
click to toggle source
# File actionview/test/template/form_tag_helper_test.rb, line 280 def test_select_tag_with_include_blank actual = select_tag "places", raw("<option>Home</option><option>Work</option><option>Pub</option>"), include_blank: true expected = %(<select id="places" name="places"><option value="" label=" "></option><option>Home</option><option>Work</option><option>Pub</option></select>) assert_dom_equal expected, actual end
test_select_tag_with_include_blank_false()
click to toggle source
# File actionview/test/template/form_tag_helper_test.rb, line 286 def test_select_tag_with_include_blank_false actual = select_tag "places", raw("<option>Home</option><option>Work</option><option>Pub</option>"), include_blank: false expected = %(<select id="places" name="places"><option>Home</option><option>Work</option><option>Pub</option></select>) assert_dom_equal expected, actual end
test_select_tag_with_include_blank_string()
click to toggle source
# File actionview/test/template/form_tag_helper_test.rb, line 292 def test_select_tag_with_include_blank_string actual = select_tag "places", raw("<option>Home</option><option>Work</option><option>Pub</option>"), include_blank: "Choose" expected = %(<select id="places" name="places"><option value="">Choose</option><option>Home</option><option>Work</option><option>Pub</option></select>) assert_dom_equal expected, actual end
test_select_tag_with_multiple()
click to toggle source
# File actionview/test/template/form_tag_helper_test.rb, line 263 def test_select_tag_with_multiple actual = select_tag "colors", raw("<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
test_select_tag_with_prompt()
click to toggle source
# File actionview/test/template/form_tag_helper_test.rb, line 298 def test_select_tag_with_prompt actual = select_tag "places", raw("<option>Home</option><option>Work</option><option>Pub</option>"), prompt: "string" expected = %(<select id="places" name="places"><option value="">string</option><option>Home</option><option>Work</option><option>Pub</option></select>) assert_dom_equal expected, actual end
test_select_tag_with_prompt_and_include_blank()
click to toggle source
# File actionview/test/template/form_tag_helper_test.rb, line 310 def test_select_tag_with_prompt_and_include_blank actual = select_tag "places", raw("<option>Home</option><option>Work</option><option>Pub</option>"), prompt: "string", include_blank: true expected = %(<select name="places" id="places"><option value="">string</option><option value="" label=" "></option><option>Home</option><option>Work</option><option>Pub</option></select>) assert_dom_equal expected, actual end
test_stringify_symbol_keys()
click to toggle source
# File actionview/test/template/form_tag_helper_test.rb, line 486 def test_stringify_symbol_keys actual = text_field_tag "title", "Hello!", id: "admin" expected = %(<input id="admin" name="title" type="text" value="Hello!" />) assert_dom_equal expected, actual end
test_submit_tag()
click to toggle source
# File actionview/test/template/form_tag_helper_test.rb, line 492 def test_submit_tag assert_dom_equal( %(<input name='commit' data-disable-with="Saving..." onclick="alert('hello!')" type="submit" value="Save" />), submit_tag("Save", onclick: "alert('hello!')", data: { disable_with: "Saving..." }) ) end
test_submit_tag_doesnt_have_data_disable_with_twice()
click to toggle source
# File actionview/test/template/form_tag_helper_test.rb, line 551 def test_submit_tag_doesnt_have_data_disable_with_twice assert_equal( %(<input type="submit" name="commit" value="Save" data-confirm="Are you sure?" data-disable-with="Processing..." />), submit_tag("Save", "data-disable-with" => "Processing...", "data-confirm" => "Are you sure?") ) end
test_submit_tag_doesnt_have_data_disable_with_twice_with_hash()
click to toggle source
# File actionview/test/template/form_tag_helper_test.rb, line 558 def test_submit_tag_doesnt_have_data_disable_with_twice_with_hash assert_equal( %(<input type="submit" name="commit" value="Save" data-disable-with="Processing..." />), submit_tag("Save", data: { disable_with: "Processing..." }) ) end
test_submit_tag_having_data_disable_with_boolean()
click to toggle source
# File actionview/test/template/form_tag_helper_test.rb, line 523 def test_submit_tag_having_data_disable_with_boolean assert_dom_equal( %(<input data-confirm="Are you sure?" name='commit' type="submit" value="Save" />), submit_tag("Save", "data-disable-with" => false, "data-confirm" => "Are you sure?") ) end
test_submit_tag_having_data_disable_with_string()
click to toggle source
# File actionview/test/template/form_tag_helper_test.rb, line 516 def test_submit_tag_having_data_disable_with_string assert_dom_equal( %(<input data-disable-with="Processing..." data-confirm="Are you sure?" name='commit' type="submit" value="Save" />), submit_tag("Save", "data-disable-with" => "Processing...", "data-confirm" => "Are you sure?") ) end
test_submit_tag_having_data_hash_disable_with_boolean()
click to toggle source
# File actionview/test/template/form_tag_helper_test.rb, line 530 def test_submit_tag_having_data_hash_disable_with_boolean assert_dom_equal( %(<input data-confirm="Are you sure?" name='commit' type="submit" value="Save" />), submit_tag("Save", data: { confirm: "Are you sure?", disable_with: false }) ) end
test_submit_tag_options_symbolize_keys_side_effects()
click to toggle source
# File actionview/test/template/form_tag_helper_test.rb, line 752 def test_submit_tag_options_symbolize_keys_side_effects options = { option: "random_option" } submit_tag "submit value", options assert_equal({ option: "random_option" }, options) end
test_submit_tag_with_confirmation()
click to toggle source
# File actionview/test/template/form_tag_helper_test.rb, line 544 def test_submit_tag_with_confirmation assert_dom_equal( %(<input name='commit' type='submit' value='Save' data-confirm="Are you sure?" data-disable-with="Save" />), submit_tag("Save", data: { confirm: "Are you sure?" }) ) end
test_submit_tag_with_no_onclick_options()
click to toggle source
# File actionview/test/template/form_tag_helper_test.rb, line 537 def test_submit_tag_with_no_onclick_options assert_dom_equal( %(<input name='commit' data-disable-with="Saving..." type="submit" value="Save" />), submit_tag("Save", data: { disable_with: "Saving..." }) ) end
test_submit_tag_with_symbol_value()
click to toggle source
# File actionview/test/template/form_tag_helper_test.rb, line 565 def test_submit_tag_with_symbol_value assert_dom_equal( %(<input data-disable-with="Save" name='commit' type="submit" value="Save" />), submit_tag(:Save) ) end
test_telephone_field_tag()
click to toggle source
# File actionview/test/template/form_tag_helper_test.rb, line 659 def test_telephone_field_tag expected = %{<input id="cell" name="cell" type="tel" />} assert_dom_equal(expected, telephone_field_tag("cell")) end
test_text_area_tag_escape_content()
click to toggle source
# File actionview/test/template/form_tag_helper_test.rb, line 351 def test_text_area_tag_escape_content actual = text_area_tag "body", "<b>hello world</b>", size: "20x40" expected = %(<textarea cols="20" id="body" name="body" rows="40">\n<b>hello world</b></textarea>) assert_dom_equal expected, actual end
test_text_area_tag_id_sanitized()
click to toggle source
# File actionview/test/template/form_tag_helper_test.rb, line 346 def test_text_area_tag_id_sanitized input_elem = root_elem(text_area_tag("item[][description]")) assert_match VALID_HTML_ID, input_elem["id"] end
test_text_area_tag_options_symbolize_keys_side_effects()
click to toggle source
# File actionview/test/template/form_tag_helper_test.rb, line 746 def test_text_area_tag_options_symbolize_keys_side_effects options = { option: "random_option" } text_area_tag "body", "hello world", options assert_equal({ option: "random_option" }, options) end
test_text_area_tag_should_disregard_size_if_its_given_as_an_integer()
click to toggle source
# File actionview/test/template/form_tag_helper_test.rb, line 340 def test_text_area_tag_should_disregard_size_if_its_given_as_an_integer actual = text_area_tag "body", "hello world", size: 20 expected = %(<textarea id="body" name="body">\nhello world</textarea>) assert_dom_equal expected, actual end
test_text_area_tag_size_string()
click to toggle source
# File actionview/test/template/form_tag_helper_test.rb, line 328 def test_text_area_tag_size_string actual = text_area_tag "body", "hello world", "size" => "20x40" expected = %(<textarea cols="20" id="body" name="body" rows="40">\nhello world</textarea>) assert_dom_equal expected, actual end
test_text_area_tag_size_symbol()
click to toggle source
# File actionview/test/template/form_tag_helper_test.rb, line 334 def test_text_area_tag_size_symbol actual = text_area_tag "body", "hello world", size: "20x40" expected = %(<textarea cols="20" id="body" name="body" rows="40">\nhello world</textarea>) assert_dom_equal expected, actual end
test_text_area_tag_unescaped_content()
click to toggle source
# File actionview/test/template/form_tag_helper_test.rb, line 357 def test_text_area_tag_unescaped_content actual = text_area_tag "body", "<b>hello world</b>", size: "20x40", escape: false expected = %(<textarea cols="20" id="body" name="body" rows="40">\n<b>hello world</b></textarea>) assert_dom_equal expected, actual end
test_text_area_tag_unescaped_nil_content()
click to toggle source
# File actionview/test/template/form_tag_helper_test.rb, line 363 def test_text_area_tag_unescaped_nil_content actual = text_area_tag "body", nil, escape: false expected = %(<textarea id="body" name="body">\n</textarea>) assert_dom_equal expected, actual end
test_text_field_tag()
click to toggle source
# File actionview/test/template/form_tag_helper_test.rb, line 369 def test_text_field_tag actual = text_field_tag "title", "Hello!" expected = %(<input id="title" name="title" type="text" value="Hello!" />) assert_dom_equal expected, actual end
test_text_field_tag_class_string()
click to toggle source
# File actionview/test/template/form_tag_helper_test.rb, line 375 def test_text_field_tag_class_string actual = text_field_tag "title", "Hello!", "class" => "admin" expected = %(<input class="admin" id="title" name="title" type="text" value="Hello!" />) assert_dom_equal expected, actual end
test_text_field_tag_disabled()
click to toggle source
# File actionview/test/template/form_tag_helper_test.rb, line 411 def test_text_field_tag_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
test_text_field_tag_id_sanitized()
click to toggle source
# File actionview/test/template/form_tag_helper_test.rb, line 429 def test_text_field_tag_id_sanitized input_elem = root_elem(text_field_tag("item[][title]")) assert_match VALID_HTML_ID, input_elem["id"] end
test_text_field_tag_maxlength_string()
click to toggle source
# File actionview/test/template/form_tag_helper_test.rb, line 405 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
test_text_field_tag_maxlength_symbol()
click to toggle source
# File actionview/test/template/form_tag_helper_test.rb, line 399 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
test_text_field_tag_size_string()
click to toggle source
# File actionview/test/template/form_tag_helper_test.rb, line 393 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
test_text_field_tag_size_symbol()
click to toggle source
# File actionview/test/template/form_tag_helper_test.rb, line 381 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
test_text_field_tag_with_ac_parameters()
click to toggle source
# File actionview/test/template/form_tag_helper_test.rb, line 387 def test_text_field_tag_with_ac_parameters actual = text_field_tag "title", ActionController::Parameters.new(key: "value") expected = %(<input id="title" name="title" type="text" value="{"key"=>"value"}" />) assert_dom_equal expected, actual end
test_text_field_tag_with_multiple_options()
click to toggle source
# File actionview/test/template/form_tag_helper_test.rb, line 423 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!" />) assert_dom_equal expected, actual end
test_text_field_tag_with_placeholder_option()
click to toggle source
# File actionview/test/template/form_tag_helper_test.rb, line 417 def test_text_field_tag_with_placeholder_option actual = text_field_tag "title", "Hello!", placeholder: "Enter search term..." expected = %(<input id="title" name="title" placeholder="Enter search term..." type="text" value="Hello!" />) assert_dom_equal expected, actual end
test_time_field_tag()
click to toggle source
# File actionview/test/template/form_tag_helper_test.rb, line 669 def test_time_field_tag expected = %{<input id="cell" name="cell" type="time" />} assert_dom_equal(expected, time_field_tag("cell")) end
test_url_field_tag()
click to toggle source
# File actionview/test/template/form_tag_helper_test.rb, line 694 def test_url_field_tag expected = %{<input id="homepage" name="homepage" type="url" />} assert_dom_equal(expected, url_field_tag("homepage")) end
test_week_field_tag()
click to toggle source
# File actionview/test/template/form_tag_helper_test.rb, line 689 def test_week_field_tag expected = %{<input id="birthday" name="birthday" type="week" />} assert_dom_equal(expected, week_field_tag("birthday")) end
url_for(options)
click to toggle source
Calls superclass method
# File actionview/test/template/form_tag_helper_test.rb, line 63 def url_for(options) if options.is_a?(Hash) "http://www.example.com" else super end end
whole_form(action = "http://www.example.com", options = {}) { |<< "</form>"| ... }
click to toggle source
# File actionview/test/template/form_tag_helper_test.rb, line 53 def whole_form(action = "http://www.example.com", options = {}) out = form_text(action, options) + hidden_fields(options) if block_given? out << yield << "</form>" end out end
Private Instance Methods
root_elem(rendered_content)
click to toggle source
# File actionview/test/template/form_tag_helper_test.rb, line 782 def root_elem(rendered_content) Nokogiri::HTML::DocumentFragment.parse(rendered_content).children.first # extract from nodeset end