Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
rails
提交
d3699114
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,体验更适合开发者的 AI 搜索 >>
未验证
提交
d3699114
编写于
3月 20, 2019
作者:
E
Eileen M. Uchitelle
提交者:
GitHub
3月 20, 2019
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #35661 from jhawthorn/lookup_context_validation
Validate types assigned to LookupContext#formats=
上级
c11d115f
0756733d
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
19 addition
and
3 deletion
+19
-3
actionview/lib/action_view/lookup_context.rb
actionview/lib/action_view/lookup_context.rb
+8
-0
actionview/lib/action_view/rendering.rb
actionview/lib/action_view/rendering.rb
+1
-1
actionview/test/template/lookup_context_test.rb
actionview/test/template/lookup_context_test.rb
+9
-1
railties/lib/rails/mailers_controller.rb
railties/lib/rails/mailers_controller.rb
+1
-1
未找到文件。
actionview/lib/action_view/lookup_context.rb
浏览文件 @
d3699114
...
...
@@ -280,7 +280,15 @@ def initialize_details(target, details)
# add :html as fallback to :js.
def
formats
=
(
values
)
if
values
values
=
values
.
dup
values
.
concat
(
default_formats
)
if
values
.
delete
"*/*"
values
.
uniq!
invalid_values
=
(
values
-
Template
::
Types
.
symbols
)
unless
invalid_values
.
empty?
raise
ArgumentError
,
"Invalid formats:
#{
invalid_values
.
map
(
&
:inspect
).
join
(
", "
)
}
"
end
if
values
==
[
:js
]
values
<<
:html
@html_fallback_for_js
=
true
...
...
actionview/lib/action_view/rendering.rb
浏览文件 @
d3699114
...
...
@@ -127,7 +127,7 @@ def _render_template(options)
# Assign the rendered format to look up context.
def
_process_format
(
format
)
super
lookup_context
.
formats
=
[
format
.
to_sym
]
lookup_context
.
formats
=
[
format
.
to_sym
]
if
format
.
to_sym
end
# Normalize args by converting render "foo" to render :action => "foo" and
...
...
actionview/test/template/lookup_context_test.rb
浏览文件 @
d3699114
...
...
@@ -67,7 +67,7 @@ def teardown
test
"handles explicitly defined */* formats fallback to :js"
do
@lookup_context
.
formats
=
[
:js
,
Mime
::
ALL
]
assert_equal
[
:js
,
*
Mime
::
SET
.
symbols
],
@lookup_context
.
formats
assert_equal
[
:js
,
*
Mime
::
SET
.
symbols
]
.
uniq
,
@lookup_context
.
formats
end
test
"adds :html fallback to :js formats"
do
...
...
@@ -75,6 +75,14 @@ def teardown
assert_equal
[
:js
,
:html
],
@lookup_context
.
formats
end
test
"raises on invalid format assignment"
do
ex
=
assert_raises
ArgumentError
do
@lookup_context
.
formats
=
[
:html
,
:invalid
,
"also bad"
]
end
assert_equal
'Invalid formats: :invalid, "also bad"'
,
ex
.
message
end
test
"provides getters and setters for locale"
do
@lookup_context
.
locale
=
:pt
assert_equal
:pt
,
@lookup_context
.
locale
...
...
railties/lib/rails/mailers_controller.rb
浏览文件 @
d3699114
...
...
@@ -38,7 +38,7 @@ def preview
end
else
@part
=
find_preferred_part
(
request
.
format
,
Mime
[
:html
],
Mime
[
:text
])
render
action:
"email"
,
layout:
false
,
formats:
%w[
html]
render
action:
"email"
,
layout:
false
,
formats:
[
:
html
]
end
else
raise
AbstractController
::
ActionNotFound
,
"Email '
#{
@email_action
}
' not found in
#{
@preview
.
name
}
"
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录