Merge pull request #4289 from rafaelfranca/patch-1

No need of html_safe here
This commit is contained in:
Santiago Pastorino 2012-01-04 08:08:19 -08:00
commit e2e4216d64
3 changed files with 10 additions and 2 deletions

@ -1093,7 +1093,7 @@ def to_check_box_tag(options = {}, checked_value = "1", unchecked_value = "0")
end end
hidden = tag("input", "name" => options["name"], "type" => "hidden", "value" => options['disabled'] && checked ? checked_value : unchecked_value) hidden = tag("input", "name" => options["name"], "type" => "hidden", "value" => options['disabled'] && checked ? checked_value : unchecked_value)
checkbox = tag("input", options) checkbox = tag("input", options)
(hidden + checkbox).html_safe hidden + checkbox
end end
def to_boolean_select_tag(options = {}) def to_boolean_select_tag(options = {})

@ -330,6 +330,7 @@ def test_text_field_with_custom_type
end end
def test_check_box def test_check_box
assert check_box("post", "secret").html_safe?
assert_dom_equal( assert_dom_equal(
'<input name="post[secret]" type="hidden" value="0" /><input checked="checked" id="post_secret" name="post[secret]" type="checkbox" value="1" />', '<input name="post[secret]" type="hidden" value="0" /><input checked="checked" id="post_secret" name="post[secret]" type="checkbox" value="1" />',
check_box("post", "secret") check_box("post", "secret")

@ -96,6 +96,13 @@ def setup
assert !@buffer.dup.html_safe? assert !@buffer.dup.html_safe?
end end
test "Should return safe buffer when added with another safe buffer" do
clean = "<script>".html_safe
result_buffer = @buffer + clean
assert result_buffer.html_safe?
assert_equal "<script>", result_buffer
end
test "Should raise an error when safe_concat is called on dirty buffers" do test "Should raise an error when safe_concat is called on dirty buffers" do
@buffer.gsub!('', '<>') @buffer.gsub!('', '<>')
assert_raise ActiveSupport::SafeBuffer::SafeConcatError do assert_raise ActiveSupport::SafeBuffer::SafeConcatError do