提交 334983ec 编写于 作者: D Daniel Rodríguez Troitiño 提交者: wycats

Recovers error_messages for ActiveRecordInstanceTag. [#4078 state:resolved]

Signed-off-by: Nwycats <wycats@gmail.com>
上级 3172db12
......@@ -295,6 +295,10 @@ def error_wrapping(html_tag)
end
end
def error_message
object.errors[@method_name]
end
def column_type
object.send(:column_for_attribute, @method_name).type
end
......
......@@ -147,6 +147,20 @@ def test_text_field_with_errors
)
end
def test_field_error_proc
old_proc = ActionView::Base.field_error_proc
ActionView::Base.field_error_proc = Proc.new do |html_tag, instance|
%(<div class=\"fieldWithErrors\">#{html_tag} <span class="error">#{[instance.error_message].join(', ')}</span></div>).html_safe
end
assert_dom_equal(
%(<div class="fieldWithErrors"><input id="post_author_name" name="post[author_name]" size="30" type="text" value="" /> <span class="error">can't be empty</span></div>),
text_field("post", "author_name")
)
ensure
ActionView::Base.field_error_proc = old_proc if old_proc
end
def test_form_with_string
assert_dom_equal(
%(<form action="create" method="post"><p><label for="post_title">Title</label><br /><input id="post_title" name="post[title]" size="30" type="text" value="Hello World" /></p>\n<p><label for="post_body">Body</label><br /><div class="fieldWithErrors"><textarea cols="40" id="post_body" name="post[body]" rows="20">Back to the hill and over it again!</textarea></div></p><input name="commit" type="submit" value="Create" /></form>),
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册