2008-05-18 06:22:34 +02:00
|
|
|
require 'abstract_unit'
|
2007-01-22 14:43:50 +01:00
|
|
|
|
2008-05-18 06:22:34 +02:00
|
|
|
class FormTagHelperTest < ActionView::TestCase
|
|
|
|
tests ActionView::Helpers::FormTagHelper
|
2007-01-22 14:43:50 +01:00
|
|
|
|
|
|
|
def setup
|
|
|
|
@controller = Class.new do
|
2007-12-21 08:48:59 +01:00
|
|
|
def url_for(options)
|
2007-01-22 14:43:50 +01:00
|
|
|
"http://www.example.com"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
@controller = @controller.new
|
|
|
|
end
|
|
|
|
|
2008-11-24 22:53:39 +01:00
|
|
|
VALID_HTML_ID = /^[A-Za-z][-_:.A-Za-z0-9]*$/ # see http://www.w3.org/TR/html4/types.html#type-name
|
|
|
|
|
2007-01-22 14:43:50 +01:00
|
|
|
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
|
|
|
|
|
2008-11-24 22:53:39 +01:00
|
|
|
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
|
|
|
|
|
2007-01-22 14:43:50 +01:00
|
|
|
def test_form_tag
|
|
|
|
actual = form_tag
|
|
|
|
expected = %(<form action="http://www.example.com" method="post">)
|
|
|
|
assert_dom_equal expected, actual
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_form_tag_multipart
|
|
|
|
actual = form_tag({}, { 'multipart' => true })
|
|
|
|
expected = %(<form action="http://www.example.com" enctype="multipart/form-data" method="post">)
|
|
|
|
assert_dom_equal expected, actual
|
|
|
|
end
|
|
|
|
|
2007-12-21 08:48:59 +01:00
|
|
|
def test_form_tag_with_method_put
|
2007-02-09 09:04:31 +01:00
|
|
|
actual = form_tag({}, { :method => :put })
|
2009-08-04 17:16:03 +02:00
|
|
|
expected = %(<form action="http://www.example.com" method="post"><div style='margin:0;padding:0;display:inline'><input type="hidden" name="_method" value="put" /></div>)
|
2007-02-09 09:04:31 +01:00
|
|
|
assert_dom_equal expected, actual
|
|
|
|
end
|
2008-10-27 07:47:01 +01:00
|
|
|
|
2007-12-21 08:48:59 +01:00
|
|
|
def test_form_tag_with_method_delete
|
|
|
|
actual = form_tag({}, { :method => :delete })
|
2009-08-04 17:16:03 +02:00
|
|
|
expected = %(<form action="http://www.example.com" method="post"><div style='margin:0;padding:0;display:inline'><input type="hidden" name="_method" value="delete" /></div>)
|
2007-12-21 08:48:59 +01:00
|
|
|
assert_dom_equal expected, actual
|
|
|
|
end
|
2007-02-09 09:04:31 +01:00
|
|
|
|
2008-10-27 07:47:01 +01:00
|
|
|
def test_form_tag_with_block_in_erb
|
|
|
|
__in_erb_template = ''
|
|
|
|
form_tag("http://example.com") { concat "Hello world!" }
|
2007-02-09 09:04:31 +01:00
|
|
|
|
2007-12-21 08:48:59 +01:00
|
|
|
expected = %(<form action="http://example.com" method="post">Hello world!</form>)
|
2008-10-27 07:47:01 +01:00
|
|
|
assert_dom_equal expected, output_buffer
|
2007-02-09 09:04:31 +01:00
|
|
|
end
|
|
|
|
|
2008-10-27 07:47:01 +01:00
|
|
|
def test_form_tag_with_block_and_method_in_erb
|
|
|
|
__in_erb_template = ''
|
|
|
|
form_tag("http://example.com", :method => :put) { concat "Hello world!" }
|
2007-02-09 09:04:31 +01:00
|
|
|
|
2009-08-04 17:16:03 +02:00
|
|
|
expected = %(<form action="http://example.com" method="post"><div style='margin:0;padding:0;display:inline'><input type="hidden" name="_method" value="put" /></div>Hello world!</form>)
|
2008-10-27 07:47:01 +01:00
|
|
|
assert_dom_equal expected, output_buffer
|
2007-02-09 09:04:31 +01:00
|
|
|
end
|
|
|
|
|
2007-01-22 14:43:50 +01:00
|
|
|
def test_hidden_field_tag
|
|
|
|
actual = hidden_field_tag "id", 3
|
|
|
|
expected = %(<input id="id" name="id" type="hidden" value="3" />)
|
|
|
|
assert_dom_equal expected, actual
|
|
|
|
end
|
|
|
|
|
2008-11-24 22:53:39 +01:00
|
|
|
def test_hidden_field_tag_id_sanitized
|
|
|
|
input_elem = root_elem(hidden_field_tag("item[][title]"))
|
|
|
|
assert_match VALID_HTML_ID, input_elem['id']
|
|
|
|
end
|
|
|
|
|
2007-12-21 08:48:59 +01:00
|
|
|
def test_file_field_tag
|
|
|
|
assert_dom_equal "<input name=\"picsplz\" type=\"file\" id=\"picsplz\" />", file_field_tag("picsplz")
|
|
|
|
end
|
|
|
|
|
|
|
|
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
|
|
|
|
|
2007-01-22 14:43:50 +01:00
|
|
|
def test_password_field_tag
|
|
|
|
actual = password_field_tag
|
|
|
|
expected = %(<input id="password" name="password" type="password" />)
|
|
|
|
assert_dom_equal expected, actual
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_radio_button_tag
|
|
|
|
actual = radio_button_tag "people", "david"
|
2007-02-09 09:04:31 +01:00
|
|
|
expected = %(<input id="people_david" name="people" type="radio" value="david" />)
|
|
|
|
assert_dom_equal expected, actual
|
|
|
|
|
|
|
|
actual = radio_button_tag("num_people", 5)
|
|
|
|
expected = %(<input id="num_people_5" name="num_people" type="radio" value="5" />)
|
|
|
|
assert_dom_equal expected, actual
|
|
|
|
|
|
|
|
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
|
2008-10-27 07:47:01 +01:00
|
|
|
|
2007-02-09 09:04:31 +01:00
|
|
|
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" />)
|
2007-01-22 14:43:50 +01:00
|
|
|
assert_dom_equal expected, actual
|
2008-10-27 07:47:01 +01:00
|
|
|
|
2007-12-21 08:48:59 +01:00
|
|
|
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
|
2007-01-22 14:43:50 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
def test_select_tag
|
2010-05-25 19:45:45 +02:00
|
|
|
actual = select_tag "people", "<option>david</option>".html_safe
|
2007-01-22 14:43:50 +01:00
|
|
|
expected = %(<select id="people" name="people"><option>david</option></select>)
|
|
|
|
assert_dom_equal expected, actual
|
|
|
|
end
|
2008-10-27 07:47:01 +01:00
|
|
|
|
2007-12-21 08:48:59 +01:00
|
|
|
def test_select_tag_with_multiple
|
2010-05-25 19:45:45 +02:00
|
|
|
actual = select_tag "colors", "<option>Red</option><option>Blue</option><option>Green</option>".html_safe, :multiple => :true
|
2007-12-21 08:48:59 +01:00
|
|
|
expected = %(<select id="colors" multiple="multiple" name="colors"><option>Red</option><option>Blue</option><option>Green</option></select>)
|
|
|
|
assert_dom_equal expected, actual
|
|
|
|
end
|
2008-10-27 07:47:01 +01:00
|
|
|
|
2007-12-21 08:48:59 +01:00
|
|
|
def test_select_tag_disabled
|
2010-05-25 19:45:45 +02:00
|
|
|
actual = select_tag "places", "<option>Home</option><option>Work</option><option>Pub</option>".html_safe, :disabled => :true
|
2007-12-21 08:48:59 +01:00
|
|
|
expected = %(<select id="places" disabled="disabled" name="places"><option>Home</option><option>Work</option><option>Pub</option></select>)
|
|
|
|
assert_dom_equal expected, actual
|
|
|
|
end
|
2007-01-22 14:43:50 +01:00
|
|
|
|
2008-11-24 22:53:39 +01:00
|
|
|
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
|
|
|
|
|
2010-05-25 19:45:45 +02:00
|
|
|
def test_select_tag_with_array_options
|
|
|
|
assert_deprecated /array/ do
|
|
|
|
select_tag "people", ["<option>david</option>"]
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2007-01-22 14:43:50 +01:00
|
|
|
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">hello world</textarea>)
|
|
|
|
assert_dom_equal expected, actual
|
|
|
|
end
|
|
|
|
|
|
|
|
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">hello world</textarea>)
|
|
|
|
assert_dom_equal expected, actual
|
|
|
|
end
|
|
|
|
|
2007-12-21 08:48:59 +01:00
|
|
|
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">hello world</textarea>)
|
|
|
|
assert_dom_equal expected, actual
|
|
|
|
end
|
|
|
|
|
2009-08-04 17:16:03 +02:00
|
|
|
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
|
|
|
|
|
|
|
|
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"><b>hello world</b></textarea>)
|
|
|
|
assert_dom_equal expected, actual
|
|
|
|
end
|
|
|
|
|
|
|
|
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"><b>hello world</b></textarea>)
|
|
|
|
assert_dom_equal expected, actual
|
|
|
|
end
|
|
|
|
|
2010-05-25 19:45:45 +02:00
|
|
|
def test_text_area_tag_unescaped_nil_content
|
|
|
|
actual = text_area_tag "body", nil, :escape => false
|
|
|
|
expected = %(<textarea id="body" name="body"></textarea>)
|
|
|
|
assert_dom_equal expected, actual
|
|
|
|
end
|
|
|
|
|
2007-01-22 14:43:50 +01:00
|
|
|
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
|
|
|
|
|
|
|
|
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
|
2008-10-27 07:47:01 +01:00
|
|
|
|
2007-12-21 08:48:59 +01:00
|
|
|
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
|
2008-10-27 07:47:01 +01:00
|
|
|
|
2007-12-21 08:48:59 +01:00
|
|
|
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
|
2008-10-27 07:47:01 +01:00
|
|
|
|
2007-12-21 08:48:59 +01:00
|
|
|
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
|
2008-10-27 07:47:01 +01:00
|
|
|
|
2007-12-21 08:48:59 +01:00
|
|
|
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
|
2008-10-27 07:47:01 +01:00
|
|
|
|
2007-12-21 08:48:59 +01:00
|
|
|
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
|
2008-10-27 07:47:01 +01:00
|
|
|
|
2007-12-21 08:48:59 +01:00
|
|
|
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
|
2007-01-22 14:43:50 +01:00
|
|
|
|
2008-11-24 22:53:39 +01:00
|
|
|
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
|
|
|
|
|
2008-05-18 06:22:34 +02:00
|
|
|
def test_label_tag_without_text
|
|
|
|
actual = label_tag "title"
|
|
|
|
expected = %(<label for="title">Title</label>)
|
|
|
|
assert_dom_equal expected, actual
|
|
|
|
end
|
|
|
|
|
2008-09-07 07:54:05 +02:00
|
|
|
def test_label_tag_with_symbol
|
|
|
|
actual = label_tag :title
|
|
|
|
expected = %(<label for="title">Title</label>)
|
|
|
|
assert_dom_equal expected, actual
|
|
|
|
end
|
|
|
|
|
2008-05-18 06:22:34 +02:00
|
|
|
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
|
|
|
|
|
|
|
|
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
|
|
|
|
|
2008-11-24 22:53:39 +01:00
|
|
|
def test_label_tag_id_sanitized
|
|
|
|
label_elem = root_elem(label_tag("item[title]"))
|
|
|
|
assert_match VALID_HTML_ID, label_elem['for']
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_boolean_options
|
2007-01-22 14:43:50 +01:00
|
|
|
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)
|
2008-11-24 22:53:39 +01:00
|
|
|
assert_dom_equal %(<input type="checkbox" />), tag(:input, :type => "checkbox", :checked => false)
|
2010-05-25 19:45:45 +02:00
|
|
|
assert_dom_equal %(<select id="people" multiple="multiple" name="people[]"><option>david</option></select>), select_tag("people", "<option>david</option>".html_safe, :multiple => true)
|
|
|
|
assert_dom_equal %(<select id="people_" multiple="multiple" name="people[]"><option>david</option></select>), select_tag("people[]", "<option>david</option>".html_safe, :multiple => true)
|
|
|
|
assert_dom_equal %(<select id="people" name="people"><option>david</option></select>), select_tag("people", "<option>david</option>".html_safe, :multiple => nil)
|
2007-01-22 14:43:50 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
def test_submit_tag
|
|
|
|
assert_dom_equal(
|
2009-08-04 17:16:03 +02:00
|
|
|
%(<input name='commit' onclick="if (window.hiddenCommit) { window.hiddenCommit.setAttribute('value', this.value); }else { hiddenCommit = document.createElement('input');hiddenCommit.type = 'hidden';hiddenCommit.value = this.value;hiddenCommit.name = this.name;this.form.appendChild(hiddenCommit); }this.setAttribute('originalValue', this.value);this.disabled = true;this.value='Saving...';alert('hello!');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;" type="submit" value="Save" />),
|
2007-01-22 14:43:50 +01:00
|
|
|
submit_tag("Save", :disable_with => "Saving...", :onclick => "alert('hello!')")
|
|
|
|
)
|
|
|
|
end
|
|
|
|
|
2008-09-07 07:54:05 +02:00
|
|
|
def test_submit_tag_with_no_onclick_options
|
|
|
|
assert_dom_equal(
|
2009-08-04 17:16:03 +02:00
|
|
|
%(<input name='commit' onclick="if (window.hiddenCommit) { window.hiddenCommit.setAttribute('value', this.value); }else { hiddenCommit = document.createElement('input');hiddenCommit.type = 'hidden';hiddenCommit.value = this.value;hiddenCommit.name = this.name;this.form.appendChild(hiddenCommit); }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;" type="submit" value="Save" />),
|
2008-09-07 07:54:05 +02:00
|
|
|
submit_tag("Save", :disable_with => "Saving...")
|
|
|
|
)
|
|
|
|
end
|
|
|
|
|
2008-05-18 06:22:34 +02:00
|
|
|
def test_submit_tag_with_confirmation
|
|
|
|
assert_dom_equal(
|
2009-03-16 15:55:30 +01:00
|
|
|
%(<input name='commit' type='submit' value='Save' onclick="if (!confirm('Are you sure?')) return false; return true;"/>),
|
2008-05-18 06:22:34 +02:00
|
|
|
submit_tag("Save", :confirm => "Are you sure?")
|
|
|
|
)
|
|
|
|
end
|
2009-03-16 15:55:30 +01:00
|
|
|
|
|
|
|
def test_submit_tag_with_confirmation_and_with_disable_with
|
|
|
|
assert_dom_equal(
|
2009-08-04 17:16:03 +02:00
|
|
|
%(<input name="commit" onclick="if (!confirm('Are you sure?')) return false; if (window.hiddenCommit) { window.hiddenCommit.setAttribute('value', this.value); }else { hiddenCommit = document.createElement('input');hiddenCommit.type = 'hidden';hiddenCommit.value = this.value;hiddenCommit.name = this.name;this.form.appendChild(hiddenCommit); }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;" type="submit" value="Save" />),
|
2009-03-16 15:55:30 +01:00
|
|
|
submit_tag("Save", :disable_with => "Saving...", :confirm => "Are you sure?")
|
|
|
|
)
|
|
|
|
end
|
|
|
|
|
2008-10-27 07:47:01 +01:00
|
|
|
def test_image_submit_tag_with_confirmation
|
|
|
|
assert_dom_equal(
|
|
|
|
%(<input type="image" src="/images/save.gif" onclick="return confirm('Are you sure?');"/>),
|
|
|
|
image_submit_tag("save.gif", :confirm => "Are you sure?")
|
|
|
|
)
|
|
|
|
end
|
|
|
|
|
2007-01-22 14:43:50 +01:00
|
|
|
def test_pass
|
|
|
|
assert_equal 1, 1
|
|
|
|
end
|
|
|
|
|
2008-10-27 07:47:01 +01:00
|
|
|
def test_field_set_tag_in_erb
|
|
|
|
__in_erb_template = ''
|
|
|
|
field_set_tag("Your details") { concat "Hello world!" }
|
2007-02-09 09:04:31 +01:00
|
|
|
|
2007-12-21 08:48:59 +01:00
|
|
|
expected = %(<fieldset><legend>Your details</legend>Hello world!</fieldset>)
|
2008-10-27 07:47:01 +01:00
|
|
|
assert_dom_equal expected, output_buffer
|
2007-02-09 09:04:31 +01:00
|
|
|
|
2010-05-25 19:45:45 +02:00
|
|
|
self.output_buffer = ''.html_safe
|
2008-10-27 07:47:01 +01:00
|
|
|
field_set_tag { concat "Hello world!" }
|
2007-12-21 08:48:59 +01:00
|
|
|
|
|
|
|
expected = %(<fieldset>Hello world!</fieldset>)
|
2008-10-27 07:47:01 +01:00
|
|
|
assert_dom_equal expected, output_buffer
|
|
|
|
|
2010-05-25 19:45:45 +02:00
|
|
|
self.output_buffer = ''.html_safe
|
2008-10-27 07:47:01 +01:00
|
|
|
field_set_tag('') { concat "Hello world!" }
|
2007-12-21 08:48:59 +01:00
|
|
|
|
|
|
|
expected = %(<fieldset>Hello world!</fieldset>)
|
2008-10-27 07:47:01 +01:00
|
|
|
assert_dom_equal expected, output_buffer
|
|
|
|
|
2010-05-25 19:45:45 +02:00
|
|
|
self.output_buffer = ''.html_safe
|
2008-10-27 07:47:01 +01:00
|
|
|
field_set_tag('', :class => 'format') { concat "Hello world!" }
|
|
|
|
|
|
|
|
expected = %(<fieldset class="format">Hello world!</fieldset>)
|
|
|
|
assert_dom_equal expected, output_buffer
|
2007-02-09 09:04:31 +01:00
|
|
|
end
|
2007-12-21 08:48:59 +01:00
|
|
|
|
|
|
|
def protect_against_forgery?
|
|
|
|
false
|
2007-02-09 09:04:31 +01:00
|
|
|
end
|
2008-11-24 22:53:39 +01:00
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def root_elem(rendered_content)
|
|
|
|
HTML::Document.new(rendered_content).root.children[0]
|
|
|
|
end
|
2007-02-09 09:04:31 +01:00
|
|
|
end
|