diff options
Diffstat (limited to 'actionpack/test/template')
-rw-r--r-- | actionpack/test/template/active_record_helper_test.rb | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/actionpack/test/template/active_record_helper_test.rb b/actionpack/test/template/active_record_helper_test.rb index 4b32f4dd48..68344e1222 100644 --- a/actionpack/test/template/active_record_helper_test.rb +++ b/actionpack/test/template/active_record_helper_test.rb @@ -1,18 +1,30 @@ require 'test/unit' require File.dirname(__FILE__) + '/../../lib/action_view/helpers/date_helper' require File.dirname(__FILE__) + '/../../lib/action_view/helpers/form_helper' +require File.dirname(__FILE__) + '/../../lib/action_view/helpers/text_helper' +require File.dirname(__FILE__) + '/../../lib/action_view/helpers/tag_helper' # require File.dirname(__FILE__) + '/../../lib/action_view/helpers/active_record_helper' class ActiveRecordHelperTest < Test::Unit::TestCase include ActionView::Helpers::FormHelper include ActionView::Helpers::ActiveRecordHelper + include ActionView::Helpers::TextHelper + include ActionView::Helpers::TagHelper Post = Struct.new("Post", :title, :author_name, :body, :secret, :written_on) Column = Struct.new("Column", :type, :name, :human_name) def setup @post = Post.new - def @post.errors() Class.new{ def on(field) field == "author_name" || field == "body" end }.new end + def @post.errors + Class.new { + def on(field) field == "author_name" || field == "body" end + def empty?() false end + def count() 1 end + def full_messages() [ "Author name can't be empty" ] end + }.new + end + def @post.new_record?() true end def @post.column_for_attribute(attr_name) @@ -73,4 +85,9 @@ class ActiveRecordHelperTest < Test::Unit::TestCase form("post") ) end + + def test_error_for_block + assert_equal "<div class=\"errorExplanation\" id=\"errorExplanation\"><h2>1 error prohibited this post from being saved</h2><p>There were problems with the following fields:</p><ul><li>Author name can't be empty</li></ul></div>", error_messages_for("post") + assert_equal "<div class=\"errorDeathByClass\" id=\"errorDeathById\"><h1>1 error prohibited this post from being saved</h1><p>There were problems with the following fields:</p><ul><li>Author name can't be empty</li></ul></div>", error_messages_for("post", :class => "errorDeathByClass", :id => "errorDeathById", :header_tag => "h1") + end end
\ No newline at end of file |