From 0d6a56d63525c708e398eb99bb56eea18444d751 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafael=20Mendon=C3=A7a=20Fran=C3=A7a?= Date: Fri, 31 Oct 2014 16:41:51 -0200 Subject: Improve test of private properties of objects in form tags --- actionview/test/template/form_helper_test.rb | 37 +++++++--------------------- 1 file changed, 9 insertions(+), 28 deletions(-) (limited to 'actionview/test/template') diff --git a/actionview/test/template/form_helper_test.rb b/actionview/test/template/form_helper_test.rb index 4169408cf9..4bbbdf4fb1 100644 --- a/actionview/test/template/form_helper_test.rb +++ b/actionview/test/template/form_helper_test.rb @@ -154,28 +154,10 @@ class FormHelperTest < ActionView::TestCase def initialize; end end - class FooObject - - def method_missing(*args) - nil - end - - private - def private_property - raise "This method should not be called." - end - end - def test_tags_base_child_without_render_method assert_raise(NotImplementedError) { FooTag.new.render } end - def test_tags_base_value_honors_public_private - test_object = Class.new { private def my_method ; end }.new - tag = ActionView::Helpers::Tags::Base.new 'test_object', :my_method, nil - assert_raise(NoMethodError) { tag.send :value, test_object } - end - def test_label assert_dom_equal('', label("post", "title")) assert_dom_equal( @@ -1804,18 +1786,17 @@ class FormHelperTest < ActionView::TestCase end def test_form_tags_do_not_call_private_properties_on_form_object - obj = FooObject.new - form_for(obj, as: "other_name", url: '/', html: { id: "edit-other-name" }) do |f| - concat f.hidden_field(:private_property) - concat f.submit('Create Foo') - end + obj = Class.new do + private - expected = whole_form("/", "edit-other-name", "new_other_name", method: "post") do - "" + - "" - end + def private_property + raise "This method should not be called." + end + end.new - assert_dom_equal expected, output_buffer + form_for(obj, as: "other_name", url: '/', html: { id: "edit-other-name" }) do |f| + assert_raise(NoMethodError) { f.hidden_field(:private_property) } + end end def test_form_for_with_method_as_part_of_html_options -- cgit v1.2.3