Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
rails
提交
4158974c
R
rails
项目概览
张重言
/
rails
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
rails
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
4158974c
编写于
1月 04, 2016
作者:
R
Rafael França
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #22764 from stevenspiel/titleize_model_name_for_default_submit_button_value
titleize the model name on default submit buttons
上级
3d590add
c74f9cc0
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
43 addition
and
3 deletion
+43
-3
actionview/lib/action_view/helpers/form_helper.rb
actionview/lib/action_view/helpers/form_helper.rb
+2
-0
actionview/test/lib/controller/fake_models.rb
actionview/test/lib/controller/fake_models.rb
+20
-0
actionview/test/template/form_helper_test.rb
actionview/test/template/form_helper_test.rb
+21
-3
未找到文件。
actionview/lib/action_view/helpers/form_helper.rb
浏览文件 @
4158974c
...
...
@@ -1922,6 +1922,8 @@ def submit_default_value
@object_name
.
to_s
.
humanize
end
model
=
model
.
downcase
defaults
=
[]
defaults
<<
:"helpers.submit.
#{
object_name
}
.
#{
key
}
"
defaults
<<
:"helpers.submit.
#{
key
}
"
...
...
actionview/test/lib/controller/fake_models.rb
浏览文件 @
4158974c
...
...
@@ -31,6 +31,26 @@ def persisted?
class
GoodCustomer
<
Customer
end
class
TicketType
<
Struct
.
new
(
:name
)
extend
ActiveModel
::
Naming
include
ActiveModel
::
Conversion
extend
ActiveModel
::
Translation
def
initialize
(
*
args
)
super
end
def
persisted
=
(
boolean
)
@persisted
=
boolean
end
def
persisted?
@persisted
end
attr_accessor
:name
end
class
Post
<
Struct
.
new
(
:title
,
:author_name
,
:body
,
:secret
,
:persisted
,
:written_on
,
:cost
)
extend
ActiveModel
::
Naming
include
ActiveModel
::
Conversion
...
...
actionview/test/template/form_helper_test.rb
浏览文件 @
4158974c
...
...
@@ -128,6 +128,8 @@ def @post.to_param; '123'; end
@post_delegator
.
title
=
'Hello World'
@car
=
Car
.
new
(
"#000FFF"
)
@ticket_type
=
TicketType
.
new
end
Routes
=
ActionDispatch
::
Routing
::
RouteSet
.
new
...
...
@@ -136,6 +138,8 @@ def @post.to_param; '123'; end
resources
:comments
end
resources
:ticket_types
namespace
:admin
do
resources
:posts
do
resources
:comments
...
...
@@ -1872,6 +1876,20 @@ def test_form_for_with_model_using_relative_model_naming
assert_dom_equal
expected
,
output_buffer
end
def
test_lowercase_model_name_default_submit_button_value
form_for
(
@ticket_type
)
do
|
f
|
concat
f
.
submit
end
expected
=
'<form class="new_ticket_type" id="new_ticket_type" action="/ticket_types" accept-charset="UTF-8" method="post">'
+
hidden_fields
+
'<input type="submit" name="commit" value="Create ticket type" data-disable-with="Create ticket type" />'
+
'</form>'
assert_dom_equal
expected
,
output_buffer
end
def
test_form_for_with_symbol_object_name
form_for
(
@post
,
as:
"other_name"
,
html:
{
id:
"create-post"
})
do
|
f
|
concat
f
.
label
(
:title
,
class:
'post_title'
)
...
...
@@ -2239,7 +2257,7 @@ def test_submit_with_object_as_new_record_and_locale_strings
end
expected
=
whole_form
(
'/posts'
,
'new_post'
,
'new_post'
)
do
"<input name='commit' data-disable-with='Create
Post' type='submit' value='Create P
ost' />"
"<input name='commit' data-disable-with='Create
post' type='submit' value='Create p
ost' />"
end
assert_dom_equal
expected
,
output_buffer
...
...
@@ -2254,7 +2272,7 @@ def test_submit_with_object_as_existing_record_and_locale_strings
end
expected
=
whole_form
(
'/posts/123'
,
'edit_post_123'
,
'edit_post'
,
method:
'patch'
)
do
"<input name='commit' data-disable-with='Confirm
Post changes' type='submit' value='Confirm P
ost changes' />"
"<input name='commit' data-disable-with='Confirm
post changes' type='submit' value='Confirm p
ost changes' />"
end
assert_dom_equal
expected
,
output_buffer
...
...
@@ -2282,7 +2300,7 @@ def test_submit_with_object_and_nested_lookup
end
expected
=
whole_form
(
'/posts/123'
,
'edit_another_post'
,
'edit_another_post'
,
method:
'patch'
)
do
"<input name='commit' data-disable-with='Update your
Post' type='submit' value='Update your P
ost' />"
"<input name='commit' data-disable-with='Update your
post' type='submit' value='Update your p
ost' />"
end
assert_dom_equal
expected
,
output_buffer
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录