aboutsummaryrefslogtreecommitdiffstats
path: root/actionview/test/template/form_helper_test.rb
diff options
context:
space:
mode:
Diffstat (limited to 'actionview/test/template/form_helper_test.rb')
-rw-r--r--actionview/test/template/form_helper_test.rb29
1 files changed, 21 insertions, 8 deletions
diff --git a/actionview/test/template/form_helper_test.rb b/actionview/test/template/form_helper_test.rb
index 6f82462425..4bbbdf4fb1 100644
--- a/actionview/test/template/form_helper_test.rb
+++ b/actionview/test/template/form_helper_test.rb
@@ -329,7 +329,7 @@ class FormHelperTest < ActionView::TestCase
end
def test_label_with_block_in_erb
- assert_equal(
+ assert_dom_equal(
%{<label for="post_message">\n Message\n <input id="post_message" name="post[message]" type="text" />\n</label>},
view.render("test/label_with_block")
)
@@ -469,8 +469,7 @@ class FormHelperTest < ActionView::TestCase
def test_text_field_doesnt_change_param_values
object_name = 'post[]'
expected = '<input id="post_123_title" name="post[123][title]" type="text" value="Hello World" />'
- assert_equal expected, text_field(object_name, "title")
- assert_equal object_name, "post[]"
+ assert_dom_equal expected, text_field(object_name, "title")
end
def test_file_field_has_no_size
@@ -1786,6 +1785,20 @@ class FormHelperTest < ActionView::TestCase
assert_dom_equal expected, output_buffer
end
+ def test_form_tags_do_not_call_private_properties_on_form_object
+ obj = Class.new do
+ private
+
+ def private_property
+ raise "This method should not be called."
+ end
+ end.new
+
+ 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
form_for(@post, url: '/', html: { id: 'create-post', method: :delete }) do |f|
concat f.text_field(:title)
@@ -3196,7 +3209,7 @@ class FormHelperTest < ActionView::TestCase
def test_form_for_with_string_url_option
form_for(@post, url: 'http://www.otherdomain.com') do |f| end
- assert_equal whole_form("http://www.otherdomain.com", "edit_post_123", "edit_post", method: "patch"), output_buffer
+ assert_dom_equal whole_form("http://www.otherdomain.com", "edit_post_123", "edit_post", method: "patch"), output_buffer
end
def test_form_for_with_hash_url_option
@@ -3210,14 +3223,14 @@ class FormHelperTest < ActionView::TestCase
form_for(@post, url: @post) do |f| end
expected = whole_form("/posts/123", "edit_post_123", "edit_post", method: "patch")
- assert_equal expected, output_buffer
+ assert_dom_equal expected, output_buffer
end
def test_form_for_with_existing_object
form_for(@post) do |f| end
expected = whole_form("/posts/123", "edit_post_123", "edit_post", method: "patch")
- assert_equal expected, output_buffer
+ assert_dom_equal expected, output_buffer
end
def test_form_for_with_new_object
@@ -3228,7 +3241,7 @@ class FormHelperTest < ActionView::TestCase
form_for(post) do |f| end
expected = whole_form("/posts", "new_post", "new_post")
- assert_equal expected, output_buffer
+ assert_dom_equal expected, output_buffer
end
def test_form_for_with_existing_object_in_list
@@ -3265,7 +3278,7 @@ class FormHelperTest < ActionView::TestCase
form_for(@post, url: "/super_posts") do |f| end
expected = whole_form("/super_posts", "edit_post_123", "edit_post", method: "patch")
- assert_equal expected, output_buffer
+ assert_dom_equal expected, output_buffer
end
def test_form_for_with_default_method_as_patch