aboutsummaryrefslogtreecommitdiffstats
path: root/actionview/test
diff options
context:
space:
mode:
authorRafael Mendonça França <rafaelmfranca@gmail.com>2014-10-31 16:41:51 -0200
committerRafael Mendonça França <rafaelmfranca@gmail.com>2014-10-31 16:41:51 -0200
commit0d6a56d63525c708e398eb99bb56eea18444d751 (patch)
treebfb56c5b04a83e109193e7eb58d5e24f31b9eb0d /actionview/test
parent1ff67d82861c11cba7896e39536565ce93d0fc08 (diff)
downloadrails-0d6a56d63525c708e398eb99bb56eea18444d751.tar.gz
rails-0d6a56d63525c708e398eb99bb56eea18444d751.tar.bz2
rails-0d6a56d63525c708e398eb99bb56eea18444d751.zip
Improve test of private properties of objects in form tags
Diffstat (limited to 'actionview/test')
-rw-r--r--actionview/test/template/form_helper_test.rb37
1 files changed, 9 insertions, 28 deletions
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 for="post_title">Title</label>', 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
- "<input id='other_name_private_property' name='other_name[private_property]' type='hidden' />" +
- "<input name='commit' value='Create Foo' type='submit' />"
- 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