aboutsummaryrefslogtreecommitdiffstats
path: root/actionview/test/template/form_helper_test.rb
diff options
context:
space:
mode:
Diffstat (limited to 'actionview/test/template/form_helper_test.rb')
-rw-r--r--actionview/test/template/form_helper_test.rb22
1 files changed, 20 insertions, 2 deletions
diff --git a/actionview/test/template/form_helper_test.rb b/actionview/test/template/form_helper_test.rb
index 90fe9fdc6a..48073225cb 100644
--- a/actionview/test/template/form_helper_test.rb
+++ b/actionview/test/template/form_helper_test.rb
@@ -10,15 +10,20 @@ class FormHelperTest < ActionView::TestCase
@output_buffer = super
end
- def setup
- super
+ teardown do
+ I18n.backend.reload!
+ end
+ setup do
# Create "label" locale for testing I18n label helpers
I18n.backend.store_translations 'label', {
activemodel: {
attributes: {
post: {
cost: "Total cost"
+ },
+ :"post/language" => {
+ spanish: "Espanol"
}
}
},
@@ -154,6 +159,12 @@ class FormHelperTest < ActionView::TestCase
end
end
+ def test_label_with_human_attribute_name_and_options
+ with_locale :label do
+ assert_dom_equal('<label for="post_language_spanish">Espanol</label>', label(:post, :language, value: "spanish"))
+ end
+ end
+
def test_label_with_locales_symbols
with_locale :label do
assert_dom_equal('<label for="post_body">Write entire text here</label>', label(:post, :body))
@@ -265,6 +276,13 @@ class FormHelperTest < ActionView::TestCase
)
end
+ def test_label_with_block_and_html
+ assert_dom_equal(
+ '<label for="post_terms">Accept <a href="/terms">Terms</a>.</label>',
+ label(:post, :terms) { 'Accept <a href="/terms">Terms</a>.'.html_safe }
+ )
+ end
+
def test_label_with_block_and_options
assert_dom_equal(
'<label for="my_for">The title, please:</label>',