diff options
author | Rui Onodera <deraru@gmail.com> | 2016-10-16 21:21:03 +0900 |
---|---|---|
committer | Rui Onodera <deraru@gmail.com> | 2018-02-27 11:41:56 +0900 |
commit | e579c7430ab94d1bf31b91d3973b26ab69c8503c (patch) | |
tree | 88cfe43e1bf902376d19934da4ca90ccf2c98b04 /actionview/test/template | |
parent | f7157e48ea233eab56844dba4203f5149d910eaa (diff) | |
download | rails-e579c7430ab94d1bf31b91d3973b26ab69c8503c.tar.gz rails-e579c7430ab94d1bf31b91d3973b26ab69c8503c.tar.bz2 rails-e579c7430ab94d1bf31b91d3973b26ab69c8503c.zip |
Change translation key of submit_tag from module_name_class_name to module_name/class_name
Currently submit_tag value translation does not support i18n key style
locale key.
It confuses me a bit because many other components support i18n key
style locale key.
I added i18n key style locale key support to submit tag.
Diffstat (limited to 'actionview/test/template')
-rw-r--r-- | actionview/test/template/form_helper/form_with_test.rb | 20 | ||||
-rw-r--r-- | actionview/test/template/form_helper_test.rb | 20 |
2 files changed, 38 insertions, 2 deletions
diff --git a/actionview/test/template/form_helper/form_with_test.rb b/actionview/test/template/form_helper/form_with_test.rb index 0d224d0c46..42905b1ec5 100644 --- a/actionview/test/template/form_helper/form_with_test.rb +++ b/actionview/test/template/form_helper/form_with_test.rb @@ -190,6 +190,9 @@ class FormWithActsLikeFormForTest < FormWithTest submit: "Save changes", another_post: { update: "Update your %{model}" + }, + "blog/post": { + update: "Update your %{model}" } } } @@ -962,7 +965,7 @@ class FormWithActsLikeFormForTest < FormWithTest end end - def test_submit_with_object_and_nested_lookup + def test_submit_with_object_which_is_overwritten_by_scope_option with_locale :submit do form_with(model: @post, scope: :another_post) do |f| concat f.submit @@ -976,6 +979,21 @@ class FormWithActsLikeFormForTest < FormWithTest end end + def test_submit_with_object_which_is_namespaced + blog_post = Blog::Post.new("And his name will be forty and four.", 44) + with_locale :submit do + form_with(model: blog_post) do |f| + concat f.submit + end + + expected = whole_form("/posts/44", method: "patch") do + "<input name='commit' data-disable-with='Update your Post' type='submit' value='Update your Post' />" + end + + assert_dom_equal expected, output_buffer + end + end + def test_fields_with_attributes_not_on_model form_with(model: @post) do |f| concat f.fields(:comment) { |c| diff --git a/actionview/test/template/form_helper_test.rb b/actionview/test/template/form_helper_test.rb index b8fad090c5..a55811b67b 100644 --- a/actionview/test/template/form_helper_test.rb +++ b/actionview/test/template/form_helper_test.rb @@ -68,6 +68,9 @@ class FormHelperTest < ActionView::TestCase submit: "Save changes", another_post: { update: "Update your %{model}" + }, + "blog/post": { + update: "Update your %{model}" } } } @@ -2271,7 +2274,7 @@ class FormHelperTest < ActionView::TestCase end end - def test_submit_with_object_and_nested_lookup + def test_submit_with_object_which_is_overwritten_by_as_option with_locale :submit do form_for(@post, as: :another_post) do |f| concat f.submit @@ -2285,6 +2288,21 @@ class FormHelperTest < ActionView::TestCase end end + def test_submit_with_object_which_is_namespaced + blog_post = Blog::Post.new("And his name will be forty and four.", 44) + with_locale :submit do + form_for(blog_post) do |f| + concat f.submit + end + + expected = whole_form("/posts/44", "edit_post_44", "edit_post", method: "patch") do + "<input name='commit' data-disable-with='Update your Post' type='submit' value='Update your Post' />" + end + + assert_dom_equal expected, output_buffer + end + end + def test_nested_fields_for @comment.body = "Hello World" form_for(@post) do |f| |