3 class DynamicFormI18nTest < Test::Unit::TestCase
4 include ActionView::Context
5 include ActionView::Helpers::DynamicForm
10 @object = stub :errors => stub(:count => 1, :full_messages => ['full_messages'])
11 @object.stubs :to_model => @object
12 @object.stubs :class => stub(:model_name => stub(:human => ""))
14 @object_name = 'book_seller'
15 @object_name_without_underscore = 'book seller'
17 stubs(:content_tag).returns 'content_tag'
19 I18n.stubs(:t).with(:'header', :locale => 'en', :scope => [:errors, :template], :count => 1, :model => '').returns "1 error prohibited this from being saved"
20 I18n.stubs(:t).with(:'body', :locale => 'en', :scope => [:errors, :template]).returns 'There were problems with the following fields:'
23 def test_error_messages_for_given_a_header_option_it_does_not_translate_header_message
24 I18n.expects(:t).with(:'header', :locale => 'en', :scope => [:errors, :template], :count => 1, :model => '').never
25 error_messages_for(:object => @object, :header_message => 'header message', :locale => 'en')
28 def test_error_messages_for_given_no_header_option_it_translates_header_message
29 I18n.expects(:t).with(:'header', :locale => 'en', :scope => [:errors, :template], :count => 1, :model => '').returns 'header message'
30 error_messages_for(:object => @object, :locale => 'en')
33 def test_error_messages_for_given_a_message_option_it_does_not_translate_message
34 I18n.expects(:t).with(:'body', :locale => 'en', :scope => [:errors, :template]).never
35 error_messages_for(:object => @object, :message => 'message', :locale => 'en')
38 def test_error_messages_for_given_no_message_option_it_translates_message
39 I18n.expects(:t).with(:'body', :locale => 'en', :scope => [:errors, :template]).returns 'There were problems with the following fields:'
40 error_messages_for(:object => @object, :locale => 'en')