diff options
author | Carsten Gehling <cg@cg-laptop.(none)> | 2009-12-29 13:06:19 +0100 |
---|---|---|
committer | José Valim <jose.valim@gmail.com> | 2010-01-02 22:27:02 +0100 |
commit | bef968d37942bfb2b7a59fca0e4451e096197c0a (patch) | |
tree | 544865b276f700657666ce5d26bd8205691f0afa /actionpack/test/template | |
parent | 653fa4c10c3e4a34cfe0fe93a2612ed178ca4455 (diff) | |
download | rails-bef968d37942bfb2b7a59fca0e4451e096197c0a.tar.gz rails-bef968d37942bfb2b7a59fca0e4451e096197c0a.tar.bz2 rails-bef968d37942bfb2b7a59fca0e4451e096197c0a.zip |
I18n label helper [#745 status:resolved]
Signed-off-by: José Valim <jose.valim@gmail.com>
Diffstat (limited to 'actionpack/test/template')
-rw-r--r-- | actionpack/test/template/form_helper_test.rb | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/actionpack/test/template/form_helper_test.rb b/actionpack/test/template/form_helper_test.rb index 44734abb18..b1e9fe99a2 100644 --- a/actionpack/test/template/form_helper_test.rb +++ b/actionpack/test/template/form_helper_test.rb @@ -6,6 +6,25 @@ class FormHelperTest < ActionView::TestCase def setup super + + # Create "label" locale for testing I18n label helpers + I18n.backend.store_translations 'label', { + :activemodel => { + :attributes => { + :post => { + :cost => "Total cost" + } + } + }, + :views => { + :labels => { + :post => { + :body => "Write entire text here" + } + } + } + } + @post = Post.new @comment = Comment.new def @post.errors() @@ -51,6 +70,27 @@ class FormHelperTest < ActionView::TestCase assert_dom_equal('<label for="post_secret">Secret?</label>', label(:post, :secret?)) end + def test_label_with_locales_strings + old_locale, I18n.locale = I18n.locale, :label + assert_dom_equal('<label for="post_body">Write entire text here</label>', label("post", "body")) + ensure + I18n.locale = old_locale + end + + def test_label_with_human_attribute_name + old_locale, I18n.locale = I18n.locale, :label + assert_dom_equal('<label for="post_cost">Total cost</label>', label(:post, :cost)) + ensure + I18n.locale = old_locale + end + + def test_label_with_locales_symbols + old_locale, I18n.locale = I18n.locale, :label + assert_dom_equal('<label for="post_body">Write entire text here</label>', label(:post, :body)) + ensure + I18n.locale = old_locale + end + def test_label_with_for_attribute_as_symbol assert_dom_equal('<label for="my_for">Title</label>', label(:post, :title, nil, :for => "my_for")) end |