aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test/template
diff options
context:
space:
mode:
authorJosé Valim <jose.valim@gmail.com>2009-07-29 21:22:56 +0200
committerJosé Valim <jose.valim@gmail.com>2009-07-29 21:22:56 +0200
commite566fc0577f336be35145b815f3fd0a554eab564 (patch)
tree718f31723bb6e6d4c9002b4e2e390b8afe33f82d /actionpack/test/template
parent7d56fd9f08795e7dddac9d31b34d707b83023c6b (diff)
parentd209aea7d88849b7c7a080d729045ce7c051ef1f (diff)
downloadrails-e566fc0577f336be35145b815f3fd0a554eab564.tar.gz
rails-e566fc0577f336be35145b815f3fd0a554eab564.tar.bz2
rails-e566fc0577f336be35145b815f3fd0a554eab564.zip
Merge branch 'master' of git://github.com/rails/rails
Diffstat (limited to 'actionpack/test/template')
-rw-r--r--actionpack/test/template/active_record_helper_i18n_test.rb7
-rw-r--r--actionpack/test/template/active_record_helper_test.rb10
2 files changed, 15 insertions, 2 deletions
diff --git a/actionpack/test/template/active_record_helper_i18n_test.rb b/actionpack/test/template/active_record_helper_i18n_test.rb
index 63032e4e5c..047f81be29 100644
--- a/actionpack/test/template/active_record_helper_i18n_test.rb
+++ b/actionpack/test/template/active_record_helper_i18n_test.rb
@@ -3,11 +3,14 @@ require 'abstract_unit'
class ActiveRecordHelperI18nTest < Test::Unit::TestCase
include ActionView::Context
include ActionView::Helpers::ActiveModelHelper
-
+
attr_reader :request
def setup
@object = stub :errors => stub(:count => 1, :full_messages => ['full_messages'])
+ @object.stubs :to_model => @object
+ @object.stubs :class => stub(:model_name => stub(:human => ""))
+
@object_name = 'book_seller'
@object_name_without_underscore = 'book seller'
@@ -39,7 +42,7 @@ class ActiveRecordHelperI18nTest < Test::Unit::TestCase
I18n.expects(:t).with('', :default => '', :count => 1, :scope => [:activerecord, :models]).once.returns ''
error_messages_for(:object => @object, :locale => 'en')
end
-
+
def test_error_messages_for_given_object_name_it_translates_object_name
I18n.expects(:t).with(:header, :locale => 'en', :scope => [:activerecord, :errors, :template], :count => 1, :model => @object_name_without_underscore).returns "1 error prohibited this #{@object_name_without_underscore} from being saved"
I18n.expects(:t).with(@object_name, :default => @object_name_without_underscore, :count => 1, :scope => [:activerecord, :models]).once.returns @object_name_without_underscore
diff --git a/actionpack/test/template/active_record_helper_test.rb b/actionpack/test/template/active_record_helper_test.rb
index b07ce6cf5d..ec3384f15d 100644
--- a/actionpack/test/template/active_record_helper_test.rb
+++ b/actionpack/test/template/active_record_helper_test.rb
@@ -295,6 +295,16 @@ class ActiveRecordHelperTest < ActionView::TestCase
assert_equal '', error_messages_for('user', :object => nil)
end
+ def test_error_messages_for_model_objects
+ error = error_messages_for(@post)
+ assert_dom_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
+
+ error = error_messages_for(@user, @post)
+ assert_dom_equal %(<div class="errorExplanation" id="errorExplanation"><h2>2 errors prohibited this user from being saved</h2><p>There were problems with the following fields:</p><ul><li>User email can't be empty</li><li>Author name can't be empty</li></ul></div>),
+ error
+ end
+
def test_form_with_string_multipart
assert_dom_equal(
%(<form action="create" enctype="multipart/form-data" 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>),