From d5f2c5c20e2f8f104a1e67ba81166874cc472b9e Mon Sep 17 00:00:00 2001 From: Joshua Cody Date: Mon, 5 May 2014 17:48:53 -0500 Subject: Include label value in i18n attribute lookup Previously, only the object and method name from the label tag were used when looking up the translation for a label. If a value is given for the label, this ought to be additionally used. The following: # form.html.erb <%= form_for @post do |f| %> <%= f.label :type, value: "long" %> <% end %> # en.yml en: activerecord: attributes: post/long: "Long-form Post" Used to simply return "long", but now it will return "Long-form Post". --- actionview/test/template/form_helper_test.rb | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'actionview/test') diff --git a/actionview/test/template/form_helper_test.rb b/actionview/test/template/form_helper_test.rb index 0ad0ae6b4b..7b680aac08 100644 --- a/actionview/test/template/form_helper_test.rb +++ b/actionview/test/template/form_helper_test.rb @@ -19,6 +19,9 @@ class FormHelperTest < ActionView::TestCase attributes: { post: { cost: "Total cost" + }, + :"post/language" => { + spanish: "Espanol" } } }, @@ -154,6 +157,12 @@ class FormHelperTest < ActionView::TestCase end end + def test_label_with_human_attribute_name_and_options + with_locale :label do + assert_dom_equal('', label(:post, :language, value: "spanish")) + end + end + def test_label_with_locales_symbols with_locale :label do assert_dom_equal('', label(:post, :body)) -- cgit v1.2.3