Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
rails
提交
6c5f43ba
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,发现更多精彩内容 >>
提交
6c5f43ba
编写于
5月 27, 2014
作者:
R
Rafael Mendonça França
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Deprecate all *_filter callbacks in favor of *_action callbacks
This is the continuation of the work started at
9d62e048
上级
cd037783
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
228 addition
and
218 deletion
+228
-218
actionpack/CHANGELOG.md
actionpack/CHANGELOG.md
+4
-0
actionpack/lib/abstract_controller/callbacks.rb
actionpack/lib/abstract_controller/callbacks.rb
+24
-20
actionpack/test/abstract/callbacks_test.rb
actionpack/test/abstract/callbacks_test.rb
+5
-3
actionpack/test/controller/filters_test.rb
actionpack/test/controller/filters_test.rb
+190
-190
actionpack/test/controller/test_case_test.rb
actionpack/test/controller/test_case_test.rb
+1
-1
railties/lib/rails/info_controller.rb
railties/lib/rails/info_controller.rb
+1
-1
railties/lib/rails/mailers_controller.rb
railties/lib/rails/mailers_controller.rb
+3
-3
未找到文件。
actionpack/CHANGELOG.md
浏览文件 @
6c5f43ba
*
Deprecate all
*_filter callbacks in favor of *
_action callbacks.
*Rafael Mendonça França*
*
Fix URL generation with
`:trailing_slash`
such that it does not add
a trailing slash after
`.:format`
...
...
actionpack/lib/abstract_controller/callbacks.rb
浏览文件 @
6c5f43ba
require
'active_support/deprecation'
module
AbstractController
module
Callbacks
extend
ActiveSupport
::
Concern
...
...
@@ -42,21 +44,23 @@ def _normalize_callback_option(options, from, to) # :nodoc:
end
end
# Skip before, after, and around action callbacks matching any of the names
# Aliased as skip_filter.
# Skip before, after, and around action callbacks matching any of the names.
#
# ==== Parameters
# * <tt>names</tt> - A list of valid names that could be used for
# callbacks. Note that skipping uses Ruby equality, so it's
# impossible to skip a callback defined using an anonymous proc
# using #skip_
filter
# using #skip_
action_callback
def
skip_action_callback
(
*
names
)
skip_before_action
(
*
names
)
skip_after_action
(
*
names
)
skip_around_action
(
*
names
)
end
alias_method
:skip_filter
,
:skip_action_callback
def
skip_filter
(
*
names
)
ActiveSupport
::
Deprecation
.
warn
(
"
#{
callback
}
_filter is deprecated and will removed in Rails 5. Use
#{
callback
}
_action instead."
)
skip_action_callback
(
*
names
)
end
# Take callback names and an optional callback proc, normalize them,
# then call the block with each callback. This allows us to abstract
...
...
@@ -85,7 +89,6 @@ def _insert_callbacks(callbacks, block = nil)
# :call-seq: before_action(names, block)
#
# Append a callback before actions. See _insert_callbacks for parameter details.
# Aliased as before_filter.
##
# :method: prepend_before_action
...
...
@@ -93,7 +96,6 @@ def _insert_callbacks(callbacks, block = nil)
# :call-seq: prepend_before_action(names, block)
#
# Prepend a callback before actions. See _insert_callbacks for parameter details.
# Aliased as prepend_before_filter.
##
# :method: skip_before_action
...
...
@@ -101,7 +103,6 @@ def _insert_callbacks(callbacks, block = nil)
# :call-seq: skip_before_action(names)
#
# Skip a callback before actions. See _insert_callbacks for parameter details.
# Aliased as skip_before_filter.
##
# :method: append_before_action
...
...
@@ -109,7 +110,6 @@ def _insert_callbacks(callbacks, block = nil)
# :call-seq: append_before_action(names, block)
#
# Append a callback before actions. See _insert_callbacks for parameter details.
# Aliased as append_before_filter.
##
# :method: after_action
...
...
@@ -117,7 +117,6 @@ def _insert_callbacks(callbacks, block = nil)
# :call-seq: after_action(names, block)
#
# Append a callback after actions. See _insert_callbacks for parameter details.
# Aliased as after_filter.
##
# :method: prepend_after_action
...
...
@@ -125,7 +124,6 @@ def _insert_callbacks(callbacks, block = nil)
# :call-seq: prepend_after_action(names, block)
#
# Prepend a callback after actions. See _insert_callbacks for parameter details.
# Aliased as prepend_after_filter.
##
# :method: skip_after_action
...
...
@@ -133,7 +131,6 @@ def _insert_callbacks(callbacks, block = nil)
# :call-seq: skip_after_action(names)
#
# Skip a callback after actions. See _insert_callbacks for parameter details.
# Aliased as skip_after_filter.
##
# :method: append_after_action
...
...
@@ -141,7 +138,6 @@ def _insert_callbacks(callbacks, block = nil)
# :call-seq: append_after_action(names, block)
#
# Append a callback after actions. See _insert_callbacks for parameter details.
# Aliased as append_after_filter.
##
# :method: around_action
...
...
@@ -149,7 +145,6 @@ def _insert_callbacks(callbacks, block = nil)
# :call-seq: around_action(names, block)
#
# Append a callback around actions. See _insert_callbacks for parameter details.
# Aliased as around_filter.
##
# :method: prepend_around_action
...
...
@@ -157,7 +152,6 @@ def _insert_callbacks(callbacks, block = nil)
# :call-seq: prepend_around_action(names, block)
#
# Prepend a callback around actions. See _insert_callbacks for parameter details.
# Aliased as prepend_around_filter.
##
# :method: skip_around_action
...
...
@@ -165,7 +159,6 @@ def _insert_callbacks(callbacks, block = nil)
# :call-seq: skip_around_action(names)
#
# Skip a callback around actions. See _insert_callbacks for parameter details.
# Aliased as skip_around_filter.
##
# :method: append_around_action
...
...
@@ -173,7 +166,6 @@ def _insert_callbacks(callbacks, block = nil)
# :call-seq: append_around_action(names, block)
#
# Append a callback around actions. See _insert_callbacks for parameter details.
# Aliased as append_around_filter.
# set up before_action, prepend_before_action, skip_before_action, etc.
# for each of before, after, and around.
...
...
@@ -184,7 +176,10 @@ def _insert_callbacks(callbacks, block = nil)
end
end
alias_method
:"
#{
callback
}
_filter"
,
:"
#{
callback
}
_action"
define_method
"
#{
callback
}
_filter"
do
|*
names
,
&
blk
|
ActiveSupport
::
Deprecation
.
warn
(
"
#{
callback
}
_filter is deprecated and will removed in Rails 5. Use
#{
callback
}
_action instead."
)
send
(
"
#{
callback
}
_action"
,
*
names
,
&
blk
)
end
define_method
"prepend_
#{
callback
}
_action"
do
|*
names
,
&
blk
|
_insert_callbacks
(
names
,
blk
)
do
|
name
,
options
|
...
...
@@ -192,7 +187,10 @@ def _insert_callbacks(callbacks, block = nil)
end
end
alias_method
:"prepend_
#{
callback
}
_filter"
,
:"prepend_
#{
callback
}
_action"
define_method
"prepend_
#{
callback
}
_filter"
do
|*
names
,
&
blk
|
ActiveSupport
::
Deprecation
.
warn
(
"prepend_
#{
callback
}
_filter is deprecated and will removed in Rails 5. Use prepend_
#{
callback
}
_action instead."
)
send
(
"prepend_
#{
callback
}
_action"
,
*
names
,
&
blk
)
end
# Skip a before, after or around callback. See _insert_callbacks
# for details on the allowed parameters.
...
...
@@ -202,11 +200,17 @@ def _insert_callbacks(callbacks, block = nil)
end
end
alias_method
:"skip_
#{
callback
}
_filter"
,
:"skip_
#{
callback
}
_action"
define_method
"skip_
#{
callback
}
_filter"
do
|*
names
,
&
blk
|
ActiveSupport
::
Deprecation
.
warn
(
"skip_
#{
callback
}
_filter is deprecated and will removed in Rails 5. Use skip_
#{
callback
}
_action instead."
)
send
(
"skip_
#{
callback
}
_action"
,
*
names
,
&
blk
)
end
# *_action is the same as append_*_action
alias_method
:"append_
#{
callback
}
_action"
,
:"
#{
callback
}
_action"
# alias_method :append_before_action, :before_action
alias_method
:"append_
#{
callback
}
_filter"
,
:"
#{
callback
}
_action"
# alias_method :append_before_filter, :before_action
define_method
"append_
#{
callback
}
_filter"
do
|*
names
,
&
blk
|
ActiveSupport
::
Deprecation
.
warn
(
"append_
#{
callback
}
_filter is deprecated and will removed in Rails 5. Use append_
#{
callback
}
_action instead."
)
send
(
"append_
#{
callback
}
_action"
,
*
names
,
&
blk
)
end
end
end
end
...
...
actionpack/test/abstract/callbacks_test.rb
浏览文件 @
6c5f43ba
...
...
@@ -267,9 +267,11 @@ class TestCallbacksWithArgs < ActiveSupport::TestCase
end
class
AliasedCallbacks
<
ControllerWithCallbacks
before_filter
:first
after_filter
:second
around_filter
:aroundz
ActiveSupport
::
Deprecation
.
silence
do
before_filter
:first
after_filter
:second
around_filter
:aroundz
end
def
first
@text
=
"Hello world"
...
...
actionpack/test/controller/filters_test.rb
浏览文件 @
6c5f43ba
...
...
@@ -2,13 +2,13 @@
class
ActionController::Base
class
<<
self
%w(append_around_
filter prepend_after_filter prepend_around_filter prepend_before_filter skip_after_filter skip_before_filter skip_filter
)
.
each
do
|
pending
|
%w(append_around_
action prepend_after_action prepend_around_action prepend_before_action skip_after_action skip_before_action skip_action_callback
)
.
each
do
|
pending
|
define_method
(
pending
)
do
|*
args
|
$stderr
.
puts
"
#{
pending
}
unimplemented:
#{
args
.
inspect
}
"
end
unless
method_defined?
(
pending
)
end
def
before_
filter
s
def
before_
action
s
filters
=
_process_action_callbacks
.
select
{
|
c
|
c
.
kind
==
:before
}
filters
.
map!
{
|
c
|
c
.
raw_filter
}
end
...
...
@@ -28,8 +28,8 @@ def assigns(key = nil)
class
FilterTest
<
ActionController
::
TestCase
class
TestController
<
ActionController
::
Base
before_
filter
:ensure_login
after_
filter
:clean_up
before_
action
:ensure_login
after_
action
:clean_up
def
show
render
:inline
=>
"ran action"
...
...
@@ -42,13 +42,13 @@ def ensure_login
end
def
clean_up
@ran_after_
filter
||=
[]
@ran_after_
filter
<<
"clean_up"
@ran_after_
action
||=
[]
@ran_after_
action
<<
"clean_up"
end
end
class
ChangingTheRequirementsController
<
TestController
before_
filter
:ensure_login
,
:except
=>
[
:go_wild
]
before_
action
:ensure_login
,
:except
=>
[
:go_wild
]
def
go_wild
render
:text
=>
"gobble"
...
...
@@ -56,9 +56,9 @@ def go_wild
end
class
TestMultipleFiltersController
<
ActionController
::
Base
before_
filter
:try_1
before_
filter
:try_2
before_
filter
:try_3
before_
action
:try_1
before_
action
:try_2
before_
action
:try_3
(
1
..
3
).
each
do
|
i
|
define_method
"fail_
#{
i
}
"
do
...
...
@@ -78,8 +78,8 @@ class TestMultipleFiltersController < ActionController::Base
end
class
RenderingController
<
ActionController
::
Base
before_
filter
:before_filter
_rendering
after_
filter
:unreached_after_filter
before_
action
:before_action
_rendering
after_
action
:unreached_after_action
def
show
@ran_action
=
true
...
...
@@ -87,29 +87,29 @@ def show
end
private
def
before_
filter
_rendering
def
before_
action
_rendering
@ran_filter
||=
[]
@ran_filter
<<
"before_
filter
_rendering"
@ran_filter
<<
"before_
action
_rendering"
render
:inline
=>
"something else"
end
def
unreached_after_
filter
@ran_filter
<<
"unreached_after_
filter
_after_render"
def
unreached_after_
action
@ran_filter
<<
"unreached_after_
action
_after_render"
end
end
class
RenderingForPrependAfter
Filter
Controller
<
RenderingController
prepend_after_
filter
:unreached_prepend_after_filter
class
RenderingForPrependAfter
Action
Controller
<
RenderingController
prepend_after_
action
:unreached_prepend_after_action
private
def
unreached_prepend_after_
filter
@ran_filter
<<
"unreached_preprend_after_
filter
_after_render"
def
unreached_prepend_after_
action
@ran_filter
<<
"unreached_preprend_after_
action
_after_render"
end
end
class
Before
Filter
RedirectionController
<
ActionController
::
Base
before_
filter
:before_filter
_redirects
after_
filter
:unreached_after_filter
class
Before
Action
RedirectionController
<
ActionController
::
Base
before_
action
:before_action
_redirects
after_
action
:unreached_after_action
def
show
@ran_action
=
true
...
...
@@ -122,23 +122,23 @@ def target_of_redirection
end
private
def
before_
filter
_redirects
def
before_
action
_redirects
@ran_filter
||=
[]
@ran_filter
<<
"before_
filter
_redirects"
@ran_filter
<<
"before_
action
_redirects"
redirect_to
(
:action
=>
'target_of_redirection'
)
end
def
unreached_after_
filter
@ran_filter
<<
"unreached_after_
filter
_after_redirection"
def
unreached_after_
action
@ran_filter
<<
"unreached_after_
action
_after_redirection"
end
end
class
Before
FilterRedirectionForPrependAfterFilterController
<
BeforeFilter
RedirectionController
prepend_after_
filter
:unreached_prepend_after_filter
_after_redirection
class
Before
ActionRedirectionForPrependAfterActionController
<
BeforeAction
RedirectionController
prepend_after_
action
:unreached_prepend_after_action
_after_redirection
private
def
unreached_prepend_after_
filter
_after_redirection
@ran_filter
<<
"unreached_prepend_after_
filter
_after_redirection"
def
unreached_prepend_after_
action
_after_redirection
@ran_filter
<<
"unreached_prepend_after_
action
_after_redirection"
end
end
...
...
@@ -151,8 +151,8 @@ def another_action
render
:inline
=>
"ran action"
end
def
show_without_
filter
render
:inline
=>
"ran action without
filter
"
def
show_without_
action
render
:inline
=>
"ran action without
action
"
end
private
...
...
@@ -168,70 +168,70 @@ def clean_up_tmp
end
class
ConditionalCollectionFilterController
<
ConditionalFilterController
before_
filter
:ensure_login
,
:except
=>
[
:show_without_filter
,
:another_action
]
before_
action
:ensure_login
,
:except
=>
[
:show_without_action
,
:another_action
]
end
class
OnlyConditionSymController
<
ConditionalFilterController
before_
filter
:ensure_login
,
:only
=>
:show
before_
action
:ensure_login
,
:only
=>
:show
end
class
ExceptConditionSymController
<
ConditionalFilterController
before_
filter
:ensure_login
,
:except
=>
:show_without_filter
before_
action
:ensure_login
,
:except
=>
:show_without_action
end
class
BeforeAndAfterConditionController
<
ConditionalFilterController
before_
filter
:ensure_login
,
:only
=>
:show
after_
filter
:clean_up_tmp
,
:only
=>
:show
before_
action
:ensure_login
,
:only
=>
:show
after_
action
:clean_up_tmp
,
:only
=>
:show
end
class
OnlyConditionProcController
<
ConditionalFilterController
before_
filter
(
:only
=>
:show
)
{
|
c
|
c
.
instance_variable_set
(
:"@ran_proc_filter
"
,
true
)
}
before_
action
(
:only
=>
:show
)
{
|
c
|
c
.
instance_variable_set
(
:"@ran_proc_action
"
,
true
)
}
end
class
ExceptConditionProcController
<
ConditionalFilterController
before_
filter
(
:except
=>
:show_without_filter
)
{
|
c
|
c
.
instance_variable_set
(
:"@ran_proc_filter
"
,
true
)
}
before_
action
(
:except
=>
:show_without_action
)
{
|
c
|
c
.
instance_variable_set
(
:"@ran_proc_action
"
,
true
)
}
end
class
ConditionalClassFilter
def
self
.
before
(
controller
)
controller
.
instance_variable_set
(
:"@ran_class_
filter
"
,
true
)
end
def
self
.
before
(
controller
)
controller
.
instance_variable_set
(
:"@ran_class_
action
"
,
true
)
end
end
class
OnlyConditionClassController
<
ConditionalFilterController
before_
filter
ConditionalClassFilter
,
:only
=>
:show
before_
action
ConditionalClassFilter
,
:only
=>
:show
end
class
ExceptConditionClassController
<
ConditionalFilterController
before_
filter
ConditionalClassFilter
,
:except
=>
:show_without_filter
before_
action
ConditionalClassFilter
,
:except
=>
:show_without_action
end
class
AnomolousYetValidConditionController
<
ConditionalFilterController
before_
filter
(
ConditionalClassFilter
,
:ensure_login
,
Proc
.
new
{
|
c
|
c
.
instance_variable_set
(
:"@ran_proc_filter1"
,
true
)},
:except
=>
:show_without_filter
)
{
|
c
|
c
.
instance_variable_set
(
:"@ran_proc_filter
2"
,
true
)}
before_
action
(
ConditionalClassFilter
,
:ensure_login
,
Proc
.
new
{
|
c
|
c
.
instance_variable_set
(
:"@ran_proc_action1"
,
true
)},
:except
=>
:show_without_action
)
{
|
c
|
c
.
instance_variable_set
(
:"@ran_proc_action
2"
,
true
)}
end
class
OnlyConditionalOptionsFilter
<
ConditionalFilterController
before_
filter
:ensure_login
,
:only
=>
:index
,
:if
=>
Proc
.
new
{
|
c
|
c
.
instance_variable_set
(
:"@ran_conditional_index_proc"
,
true
)
}
before_
action
:ensure_login
,
:only
=>
:index
,
:if
=>
Proc
.
new
{
|
c
|
c
.
instance_variable_set
(
:"@ran_conditional_index_proc"
,
true
)
}
end
class
ConditionalOptionsFilter
<
ConditionalFilterController
before_
filter
:ensure_login
,
:if
=>
Proc
.
new
{
|
c
|
true
}
before_
filter
:clean_up_tmp
,
:if
=>
Proc
.
new
{
|
c
|
false
}
before_
action
:ensure_login
,
:if
=>
Proc
.
new
{
|
c
|
true
}
before_
action
:clean_up_tmp
,
:if
=>
Proc
.
new
{
|
c
|
false
}
end
class
ConditionalOptionsSkipFilter
<
ConditionalFilterController
before_
filter
:ensure_login
before_
filter
:clean_up_tmp
before_
action
:ensure_login
before_
action
:clean_up_tmp
skip_before_
filter
:ensure_login
,
if:
->
{
false
}
skip_before_
filter
:clean_up_tmp
,
if:
->
{
true
}
skip_before_
action
:ensure_login
,
if:
->
{
false
}
skip_before_
action
:clean_up_tmp
,
if:
->
{
true
}
end
class
ClassController
<
ConditionalFilterController
before_
filter
ConditionalClassFilter
before_
action
ConditionalClassFilter
end
class
PrependingController
<
TestController
prepend_before_
filter
:wonderful_life
# skip_before_
filter
:fire_flash
prepend_before_
action
:wonderful_life
# skip_before_
action
:fire_flash
private
def
wonderful_life
...
...
@@ -241,8 +241,8 @@ def wonderful_life
end
class
SkippingAndLimitedController
<
TestController
skip_before_
filter
:ensure_login
before_
filter
:ensure_login
,
:only
=>
:index
skip_before_
action
:ensure_login
before_
action
:ensure_login
,
:only
=>
:index
def
index
render
:text
=>
'ok'
...
...
@@ -254,9 +254,9 @@ def public
end
class
SkippingAndReorderingController
<
TestController
skip_before_
filter
:ensure_login
before_
filter
:find_record
before_
filter
:ensure_login
skip_before_
action
:ensure_login
before_
action
:find_record
before_
action
:ensure_login
def
index
render
:text
=>
'ok'
...
...
@@ -270,10 +270,10 @@ def find_record
end
class
ConditionalSkippingController
<
TestController
skip_before_
filter
:ensure_login
,
:only
=>
[
:login
]
skip_after_
filter
:clean_up
,
:only
=>
[
:login
]
skip_before_
action
:ensure_login
,
:only
=>
[
:login
]
skip_after_
action
:clean_up
,
:only
=>
[
:login
]
before_
filter
:find_user
,
:only
=>
[
:change_password
]
before_
action
:find_user
,
:only
=>
[
:change_password
]
def
login
render
:inline
=>
"ran action"
...
...
@@ -291,8 +291,8 @@ def find_user
end
class
ConditionalParentOfConditionalSkippingController
<
ConditionalFilterController
before_
filter
:conditional_in_parent_before
,
:only
=>
[
:show
,
:another_action
]
after_
filter
:conditional_in_parent_after
,
:only
=>
[
:show
,
:another_action
]
before_
action
:conditional_in_parent_before
,
:only
=>
[
:show
,
:another_action
]
after_
action
:conditional_in_parent_after
,
:only
=>
[
:show
,
:another_action
]
private
...
...
@@ -308,20 +308,20 @@ def conditional_in_parent_after
end
class
ChildOfConditionalParentController
<
ConditionalParentOfConditionalSkippingController
skip_before_
filter
:conditional_in_parent_before
,
:only
=>
:another_action
skip_after_
filter
:conditional_in_parent_after
,
:only
=>
:another_action
skip_before_
action
:conditional_in_parent_before
,
:only
=>
:another_action
skip_after_
action
:conditional_in_parent_after
,
:only
=>
:another_action
end
class
AnotherChildOfConditionalParentController
<
ConditionalParentOfConditionalSkippingController
skip_before_
filter
:conditional_in_parent_before
,
:only
=>
:show
skip_before_
action
:conditional_in_parent_before
,
:only
=>
:show
end
class
ProcController
<
PrependingController
before_
filter
(
proc
{
|
c
|
c
.
instance_variable_set
(
:"@ran_proc_filter
"
,
true
)
})
before_
action
(
proc
{
|
c
|
c
.
instance_variable_set
(
:"@ran_proc_action
"
,
true
)
})
end
class
ImplicitProcController
<
PrependingController
before_
filter
{
|
c
|
c
.
instance_variable_set
(
:"@ran_proc_filter
"
,
true
)
}
before_
action
{
|
c
|
c
.
instance_variable_set
(
:"@ran_proc_action
"
,
true
)
}
end
class
AuditFilter
...
...
@@ -367,7 +367,7 @@ def around(controller)
end
class
AuditController
<
ActionController
::
Base
before_
filter
(
AuditFilter
)
before_
action
(
AuditFilter
)
def
show
render
:text
=>
"hello"
...
...
@@ -375,14 +375,14 @@ def show
end
class
AroundFilterController
<
PrependingController
around_
filter
AroundFilter
.
new
around_
action
AroundFilter
.
new
end
class
BeforeAfterClassFilterController
<
PrependingController
begin
filter
=
AroundFilter
.
new
before_
filter
filter
after_
filter
filter
before_
action
filter
after_
action
filter
end
end
...
...
@@ -394,18 +394,18 @@ def initialize
super
()
end
before_
filter
{
|
c
|
c
.
class
.
execution_log
<<
" before procfilter "
}
prepend_around_
filter
AroundFilter
.
new
before_
action
{
|
c
|
c
.
class
.
execution_log
<<
" before procfilter "
}
prepend_around_
action
AroundFilter
.
new
after_
filter
{
|
c
|
c
.
class
.
execution_log
<<
" after procfilter "
}
append_around_
filter
AppendedAroundFilter
.
new
after_
action
{
|
c
|
c
.
class
.
execution_log
<<
" after procfilter "
}
append_around_
action
AppendedAroundFilter
.
new
end
class
MixedSpecializationController
<
ActionController
::
Base
class
OutOfOrder
<
StandardError
;
end
before_
filter
:first
before_
filter
:second
,
:only
=>
:foo
before_
action
:first
before_
action
:second
,
:only
=>
:foo
def
foo
render
:text
=>
'foo'
...
...
@@ -426,7 +426,7 @@ def second
end
class
DynamicDispatchController
<
ActionController
::
Base
before_
filter
:choose
before_
action
:choose
%w(foo bar baz)
.
each
do
|
action
|
define_method
(
action
)
{
render
:text
=>
action
}
...
...
@@ -439,9 +439,9 @@ def choose
end
class
PrependingBeforeAndAfterController
<
ActionController
::
Base
prepend_before_
filter
:before_all
prepend_after_
filter
:after_all
before_
filter
:between_before_all_and_after_all
prepend_before_
action
:before_all
prepend_after_
action
:after_all
before_
action
:between_before_all_and_after_all
def
before_all
@ran_filter
||=
[]
...
...
@@ -473,7 +473,7 @@ def around(controller)
end
class
RescuedController
<
ActionController
::
Base
around_
filter
RescuingAroundFilterWithBlock
.
new
around_
action
RescuingAroundFilterWithBlock
.
new
def
show
raise
ErrorToRescue
.
new
(
"Something made the bad noise."
)
...
...
@@ -482,10 +482,10 @@ def show
class
NonYieldingAroundFilterController
<
ActionController
::
Base
before_
filter
:filter_one
around_
filter
:non_yielding_filter
before_
filter
:filter
_two
after_
filter
:filter
_three
before_
action
:filter_one
around_
action
:non_yielding_action
before_
action
:action
_two
after_
action
:action
_three
def
index
render
:inline
=>
"index"
...
...
@@ -498,24 +498,24 @@ def filter_one
@filters
<<
"filter_one"
end
def
filter
_two
@filters
<<
"
filter
_two"
def
action
_two
@filters
<<
"
action
_two"
end
def
non_yielding_
filter
def
non_yielding_
action
@filters
<<
"it didn't yield"
@filter_return_value
end
def
filter
_three
@filters
<<
"
filter
_three"
def
action
_three
@filters
<<
"
action
_three"
end
end
class
ImplicitActionsController
<
ActionController
::
Base
before_
filter
:find_only
,
:only
=>
:edit
before_
filter
:find_except
,
:except
=>
:edit
before_
action
:find_only
,
:only
=>
:edit
before_
action
:find_except
,
:except
=>
:edit
private
...
...
@@ -528,7 +528,7 @@ def find_except
end
end
def
test_non_yielding_around_
filter
s_not_returning_false_do_not_raise
def
test_non_yielding_around_
action
s_not_returning_false_do_not_raise
controller
=
NonYieldingAroundFilterController
.
new
controller
.
instance_variable_set
"@filter_return_value"
,
true
assert_nothing_raised
do
...
...
@@ -536,7 +536,7 @@ def test_non_yielding_around_filters_not_returning_false_do_not_raise
end
end
def
test_non_yielding_around_
filter
s_returning_false_do_not_raise
def
test_non_yielding_around_
action
s_returning_false_do_not_raise
controller
=
NonYieldingAroundFilterController
.
new
controller
.
instance_variable_set
"@filter_return_value"
,
false
assert_nothing_raised
do
...
...
@@ -544,64 +544,64 @@ def test_non_yielding_around_filters_returning_false_do_not_raise
end
end
def
test_after_
filters_are_not_run_if_around_filter
_returns_false
def
test_after_
actions_are_not_run_if_around_action
_returns_false
controller
=
NonYieldingAroundFilterController
.
new
controller
.
instance_variable_set
"@filter_return_value"
,
false
test_process
(
controller
,
"index"
)
assert_equal
[
"filter_one"
,
"it didn't yield"
],
controller
.
assigns
[
'filters'
]
end
def
test_after_
filters_are_not_run_if_around_filter
_does_not_yield
def
test_after_
actions_are_not_run_if_around_action
_does_not_yield
controller
=
NonYieldingAroundFilterController
.
new
controller
.
instance_variable_set
"@filter_return_value"
,
true
test_process
(
controller
,
"index"
)
assert_equal
[
"filter_one"
,
"it didn't yield"
],
controller
.
assigns
[
'filters'
]
end
def
test_added_
filter
_to_inheritance_graph
assert_equal
[
:ensure_login
],
TestController
.
before_
filter
s
def
test_added_
action
_to_inheritance_graph
assert_equal
[
:ensure_login
],
TestController
.
before_
action
s
end
def
test_base_class_in_isolation
assert_equal
[
],
ActionController
::
Base
.
before_
filter
s
assert_equal
[
],
ActionController
::
Base
.
before_
action
s
end
def
test_prepending_
filter
assert_equal
[
:wonderful_life
,
:ensure_login
],
PrependingController
.
before_
filter
s
def
test_prepending_
action
assert_equal
[
:wonderful_life
,
:ensure_login
],
PrependingController
.
before_
action
s
end
def
test_running_
filter
s
def
test_running_
action
s
test_process
(
PrependingController
)
assert_equal
%w( wonderful_life ensure_login )
,
assigns
[
"ran_filter"
]
end
def
test_running_
filter
s_with_proc
def
test_running_
action
s_with_proc
test_process
(
ProcController
)
assert
assigns
[
"ran_proc_
filter
"
]
assert
assigns
[
"ran_proc_
action
"
]
end
def
test_running_
filter
s_with_implicit_proc
def
test_running_
action
s_with_implicit_proc
test_process
(
ImplicitProcController
)
assert
assigns
[
"ran_proc_
filter
"
]
assert
assigns
[
"ran_proc_
action
"
]
end
def
test_running_
filter
s_with_class
def
test_running_
action
s_with_class
test_process
(
AuditController
)
assert
assigns
[
"was_audited"
]
end
def
test_running_anomolous_yet_valid_condition_
filter
s
def
test_running_anomolous_yet_valid_condition_
action
s
test_process
(
AnomolousYetValidConditionController
)
assert_equal
%w( ensure_login )
,
assigns
[
"ran_filter"
]
assert
assigns
[
"ran_class_
filter
"
]
assert
assigns
[
"ran_proc_
filter
1"
]
assert
assigns
[
"ran_proc_
filter
2"
]
assert
assigns
[
"ran_class_
action
"
]
assert
assigns
[
"ran_proc_
action
1"
]
assert
assigns
[
"ran_proc_
action
2"
]
test_process
(
AnomolousYetValidConditionController
,
"show_without_
filter
"
)
test_process
(
AnomolousYetValidConditionController
,
"show_without_
action
"
)
assert_nil
assigns
[
"ran_filter"
]
assert
!
assigns
[
"ran_class_
filter
"
]
assert
!
assigns
[
"ran_proc_
filter
1"
]
assert
!
assigns
[
"ran_proc_
filter
2"
]
assert
!
assigns
[
"ran_class_
action
"
]
assert
!
assigns
[
"ran_proc_
action
1"
]
assert
!
assigns
[
"ran_proc_
action
2"
]
end
def
test_running_conditional_options
...
...
@@ -614,59 +614,59 @@ def test_running_conditional_skip_options
assert_equal
%w( ensure_login )
,
assigns
[
"ran_filter"
]
end
def
test_skipping_class_
filter
s
def
test_skipping_class_
action
s
test_process
(
ClassController
)
assert_equal
true
,
assigns
[
"ran_class_
filter
"
]
assert_equal
true
,
assigns
[
"ran_class_
action
"
]
skipping_class_controller
=
Class
.
new
(
ClassController
)
do
skip_before_
filter
ConditionalClassFilter
skip_before_
action
ConditionalClassFilter
end
test_process
(
skipping_class_controller
)
assert_nil
assigns
[
'ran_class_
filter
'
]
assert_nil
assigns
[
'ran_class_
action
'
]
end
def
test_running_collection_condition_
filter
s
def
test_running_collection_condition_
action
s
test_process
(
ConditionalCollectionFilterController
)
assert_equal
%w( ensure_login )
,
assigns
[
"ran_filter"
]
test_process
(
ConditionalCollectionFilterController
,
"show_without_
filter
"
)
test_process
(
ConditionalCollectionFilterController
,
"show_without_
action
"
)
assert_nil
assigns
[
"ran_filter"
]
test_process
(
ConditionalCollectionFilterController
,
"another_action"
)
assert_nil
assigns
[
"ran_filter"
]
end
def
test_running_only_condition_
filter
s
def
test_running_only_condition_
action
s
test_process
(
OnlyConditionSymController
)
assert_equal
%w( ensure_login )
,
assigns
[
"ran_filter"
]
test_process
(
OnlyConditionSymController
,
"show_without_
filter
"
)
test_process
(
OnlyConditionSymController
,
"show_without_
action
"
)
assert_nil
assigns
[
"ran_filter"
]
test_process
(
OnlyConditionProcController
)
assert
assigns
[
"ran_proc_
filter
"
]
test_process
(
OnlyConditionProcController
,
"show_without_
filter
"
)
assert
!
assigns
[
"ran_proc_
filter
"
]
assert
assigns
[
"ran_proc_
action
"
]
test_process
(
OnlyConditionProcController
,
"show_without_
action
"
)
assert
!
assigns
[
"ran_proc_
action
"
]
test_process
(
OnlyConditionClassController
)
assert
assigns
[
"ran_class_
filter
"
]
test_process
(
OnlyConditionClassController
,
"show_without_
filter
"
)
assert
!
assigns
[
"ran_class_
filter
"
]
assert
assigns
[
"ran_class_
action
"
]
test_process
(
OnlyConditionClassController
,
"show_without_
action
"
)
assert
!
assigns
[
"ran_class_
action
"
]
end
def
test_running_except_condition_
filter
s
def
test_running_except_condition_
action
s
test_process
(
ExceptConditionSymController
)
assert_equal
%w( ensure_login )
,
assigns
[
"ran_filter"
]
test_process
(
ExceptConditionSymController
,
"show_without_
filter
"
)
test_process
(
ExceptConditionSymController
,
"show_without_
action
"
)
assert_nil
assigns
[
"ran_filter"
]
test_process
(
ExceptConditionProcController
)
assert
assigns
[
"ran_proc_
filter
"
]
test_process
(
ExceptConditionProcController
,
"show_without_
filter
"
)
assert
!
assigns
[
"ran_proc_
filter
"
]
assert
assigns
[
"ran_proc_
action
"
]
test_process
(
ExceptConditionProcController
,
"show_without_
action
"
)
assert
!
assigns
[
"ran_proc_
action
"
]
test_process
(
ExceptConditionClassController
)
assert
assigns
[
"ran_class_
filter
"
]
test_process
(
ExceptConditionClassController
,
"show_without_
filter
"
)
assert
!
assigns
[
"ran_class_
filter
"
]
assert
assigns
[
"ran_class_
action
"
]
test_process
(
ExceptConditionClassController
,
"show_without_
action
"
)
assert
!
assigns
[
"ran_class_
action
"
]
end
def
test_running_only_condition_and_conditional_options
...
...
@@ -674,70 +674,70 @@ def test_running_only_condition_and_conditional_options
assert_not
assigns
[
"ran_conditional_index_proc"
]
end
def
test_running_before_and_after_condition_
filter
s
def
test_running_before_and_after_condition_
action
s
test_process
(
BeforeAndAfterConditionController
)
assert_equal
%w( ensure_login clean_up_tmp)
,
assigns
[
"ran_filter"
]
test_process
(
BeforeAndAfterConditionController
,
"show_without_
filter
"
)
test_process
(
BeforeAndAfterConditionController
,
"show_without_
action
"
)
assert_nil
assigns
[
"ran_filter"
]
end
def
test_around_
filter
def
test_around_
action
test_process
(
AroundFilterController
)
assert
assigns
[
"before_ran"
]
assert
assigns
[
"after_ran"
]
end
def
test_before_after_class_
filter
def
test_before_after_class_
action
test_process
(
BeforeAfterClassFilterController
)
assert
assigns
[
"before_ran"
]
assert
assigns
[
"after_ran"
]
end
def
test_having_properties_in_around_
filter
def
test_having_properties_in_around_
action
test_process
(
AroundFilterController
)
assert_equal
"before and after"
,
assigns
[
"execution_log"
]
end
def
test_prepending_and_appending_around_
filter
def
test_prepending_and_appending_around_
action
test_process
(
MixedFilterController
)
assert_equal
" before aroundfilter before procfilter before appended aroundfilter "
+
" after appended aroundfilter after procfilter after aroundfilter "
,
MixedFilterController
.
execution_log
end
def
test_rendering_breaks_
filter
ing_chain
def
test_rendering_breaks_
action
ing_chain
response
=
test_process
(
RenderingController
)
assert_equal
"something else"
,
response
.
body
assert
!
assigns
[
"ran_action"
]
end
def
test_before_
filter_rendering_breaks_filtering_chain_for_after_filter
def
test_before_
action_rendering_breaks_actioning_chain_for_after_action
test_process
(
RenderingController
)
assert_equal
%w( before_
filter
_rendering )
,
assigns
[
"ran_filter"
]
assert_equal
%w( before_
action
_rendering )
,
assigns
[
"ran_filter"
]
assert
!
assigns
[
"ran_action"
]
end
def
test_before_
filter_redirects_breaks_filtering_chain_for_after_filter
test_process
(
Before
Filter
RedirectionController
)
def
test_before_
action_redirects_breaks_actioning_chain_for_after_action
test_process
(
Before
Action
RedirectionController
)
assert_response
:redirect
assert_equal
"http://test.host/filter_test/before_
filter
_redirection/target_of_redirection"
,
redirect_to_url
assert_equal
%w( before_
filter
_redirects )
,
assigns
[
"ran_filter"
]
assert_equal
"http://test.host/filter_test/before_
action
_redirection/target_of_redirection"
,
redirect_to_url
assert_equal
%w( before_
action
_redirects )
,
assigns
[
"ran_filter"
]
end
def
test_before_
filter_rendering_breaks_filtering_chain_for_preprend_after_filter
test_process
(
RenderingForPrependAfter
Filter
Controller
)
assert_equal
%w( before_
filter
_rendering )
,
assigns
[
"ran_filter"
]
def
test_before_
action_rendering_breaks_actioning_chain_for_preprend_after_action
test_process
(
RenderingForPrependAfter
Action
Controller
)
assert_equal
%w( before_
action
_rendering )
,
assigns
[
"ran_filter"
]
assert
!
assigns
[
"ran_action"
]
end
def
test_before_
filter_redirects_breaks_filtering_chain_for_preprend_after_filter
test_process
(
Before
FilterRedirectionForPrependAfterFilter
Controller
)
def
test_before_
action_redirects_breaks_actioning_chain_for_preprend_after_action
test_process
(
Before
ActionRedirectionForPrependAfterAction
Controller
)
assert_response
:redirect
assert_equal
"http://test.host/filter_test/before_
filter_redirection_for_prepend_after_filter
/target_of_redirection"
,
redirect_to_url
assert_equal
%w( before_
filter
_redirects )
,
assigns
[
"ran_filter"
]
assert_equal
"http://test.host/filter_test/before_
action_redirection_for_prepend_after_action
/target_of_redirection"
,
redirect_to_url
assert_equal
%w( before_
action
_redirects )
,
assigns
[
"ran_filter"
]
end
def
test_
filter
s_with_mixed_specialization_run_in_order
def
test_
action
s_with_mixed_specialization_run_in_order
assert_nothing_raised
do
response
=
test_process
(
MixedSpecializationController
,
'bar'
)
assert_equal
'bar'
,
response
.
body
...
...
@@ -758,7 +758,7 @@ def test_dynamic_dispatch
end
end
def
test_running_prepended_before_and_after_
filter
def
test_running_prepended_before_and_after_
action
test_process
(
PrependingBeforeAndAfterController
)
assert_equal
%w( before_all between_before_all_and_after_all after_all )
,
assigns
[
"ran_filter"
]
end
...
...
@@ -775,26 +775,26 @@ def test_skipping_and_reordering_controller
assert_equal
%w( find_record ensure_login )
,
assigns
[
"ran_filter"
]
end
def
test_conditional_skipping_of_
filter
s
def
test_conditional_skipping_of_
action
s
test_process
(
ConditionalSkippingController
,
"login"
)
assert_nil
assigns
[
"ran_filter"
]
test_process
(
ConditionalSkippingController
,
"change_password"
)
assert_equal
%w( ensure_login find_user )
,
assigns
[
"ran_filter"
]
test_process
(
ConditionalSkippingController
,
"login"
)
assert
!
@controller
.
instance_variable_defined?
(
"@ran_after_
filter
"
)
assert
!
@controller
.
instance_variable_defined?
(
"@ran_after_
action
"
)
test_process
(
ConditionalSkippingController
,
"change_password"
)
assert_equal
%w( clean_up )
,
@controller
.
instance_variable_get
(
"@ran_after_
filter
"
)
assert_equal
%w( clean_up )
,
@controller
.
instance_variable_get
(
"@ran_after_
action
"
)
end
def
test_conditional_skipping_of_
filters_when_parent_filter
_is_also_conditional
def
test_conditional_skipping_of_
actions_when_parent_action
_is_also_conditional
test_process
(
ChildOfConditionalParentController
)
assert_equal
%w( conditional_in_parent_before conditional_in_parent_after )
,
assigns
[
'ran_filter'
]
test_process
(
ChildOfConditionalParentController
,
'another_action'
)
assert_nil
assigns
[
'ran_filter'
]
end
def
test_condition_skipping_of_
filter
s_when_siblings_also_have_conditions
def
test_condition_skipping_of_
action
s_when_siblings_also_have_conditions
test_process
(
ChildOfConditionalParentController
)
assert_equal
%w( conditional_in_parent_before conditional_in_parent_after )
,
assigns
[
'ran_filter'
]
test_process
(
AnotherChildOfConditionalParentController
)
...
...
@@ -808,7 +808,7 @@ def test_changing_the_requirements
assert_nil
assigns
[
'ran_filter'
]
end
def
test_a_rescuing_around_
filter
def
test_a_rescuing_around_
action
response
=
nil
assert_nothing_raised
do
response
=
test_process
(
RescuedController
)
...
...
@@ -818,7 +818,7 @@ def test_a_rescuing_around_filter
assert_equal
(
"I rescued this: #<FilterTest::ErrorToRescue: Something made the bad noise.>"
,
response
.
body
)
end
def
test_
filter
s_obey_only_and_except_for_implicit_actions
def
test_
action
s_obey_only_and_except_for_implicit_actions
test_process
(
ImplicitActionsController
,
'show'
)
assert_equal
'Except'
,
assigns
(
:except
)
assert_nil
assigns
(
:only
)
...
...
@@ -852,7 +852,7 @@ class DefaultFilter
include
AroundExceptions
end
module_eval
%w(raises_before raises_after raises_both no_raise no_
filter
)
.
map
{
|
action
|
"def
#{
action
}
; default_action end"
}.
join
(
"
\n
"
)
module_eval
%w(raises_before raises_after raises_both no_raise no_
action
)
.
map
{
|
action
|
"def
#{
action
}
; default_action end"
}.
join
(
"
\n
"
)
private
def
default_action
...
...
@@ -861,9 +861,9 @@ def default_action
end
class
ControllerWithSymbolAsFilter
<
PostsController
around_
filter
:raise_before
,
:only
=>
:raises_before
around_
filter
:raise_after
,
:only
=>
:raises_after
around_
filter
:without_exception
,
:only
=>
:no_raise
around_
action
:raise_before
,
:only
=>
:raises_before
around_
action
:raise_after
,
:only
=>
:raises_after
around_
action
:without_exception
,
:only
=>
:no_raise
private
def
raise_before
...
...
@@ -895,7 +895,7 @@ def self.around(controller)
end
end
around_
filter
YieldingFilter
,
:only
=>
:raises_after
around_
action
YieldingFilter
,
:only
=>
:raises_after
end
class
ControllerWithFilterInstance
<
PostsController
...
...
@@ -906,11 +906,11 @@ def around(controller)
end
end
around_
filter
YieldingFilter
.
new
,
:only
=>
:raises_after
around_
action
YieldingFilter
.
new
,
:only
=>
:raises_after
end
class
ControllerWithProcFilter
<
PostsController
around_
filter
(
:only
=>
:no_raise
)
do
|
c
,
b
|
around_
action
(
:only
=>
:no_raise
)
do
|
c
,
b
|
c
.
instance_variable_set
(
:"@before"
,
true
)
b
.
call
c
.
instance_variable_set
(
:"@after"
,
true
)
...
...
@@ -918,14 +918,14 @@ class ControllerWithProcFilter < PostsController
end
class
ControllerWithNestedFilters
<
ControllerWithSymbolAsFilter
around_
filter
:raise_before
,
:raise_after
,
:without_exception
,
:only
=>
:raises_both
around_
action
:raise_before
,
:raise_after
,
:without_exception
,
:only
=>
:raises_both
end
class
ControllerWithAllTypesOfFilters
<
PostsController
before_
filter
:before
around_
filter
:around
after_
filter
:after
around_
filter
:around_again
before_
action
:before
around_
action
:around
after_
action
:after
around_
action
:around_again
private
def
before
...
...
@@ -951,8 +951,8 @@ def around_again
end
class
ControllerWithTwoLessFilters
<
ControllerWithAllTypesOfFilters
skip_
filter
:around_again
skip_
filter
:after
skip_
action_callback
:around_again
skip_
action_callback
:after
end
class
YieldingAroundFiltersTest
<
ActionController
::
TestCase
...
...
@@ -963,7 +963,7 @@ def test_base
assert_nothing_raised
{
test_process
(
controller
,
'no_raise'
)
}
assert_nothing_raised
{
test_process
(
controller
,
'raises_before'
)
}
assert_nothing_raised
{
test_process
(
controller
,
'raises_after'
)
}
assert_nothing_raised
{
test_process
(
controller
,
'no_
filter
'
)
}
assert_nothing_raised
{
test_process
(
controller
,
'no_
action
'
)
}
end
def
test_with_symbol
...
...
@@ -992,7 +992,7 @@ def test_with_proc
assert
assigns
[
'after'
]
end
def
test_nested_
filter
s
def
test_nested_
action
s
controller
=
ControllerWithNestedFilters
assert_nothing_raised
do
begin
...
...
@@ -1008,31 +1008,31 @@ def test_nested_filters
end
end
def
test_
filter_order_with_all_filter
_types
def
test_
action_order_with_all_action
_types
test_process
(
ControllerWithAllTypesOfFilters
,
'no_raise'
)
assert_equal
'before around (before yield) around_again (before yield) around_again (after yield) after around (after yield)'
,
assigns
[
'ran_filter'
].
join
(
' '
)
end
def
test_
filter_order_with_skip_filter
_method
def
test_
action_order_with_skip_action
_method
test_process
(
ControllerWithTwoLessFilters
,
'no_raise'
)
assert_equal
'before around (before yield) around (after yield)'
,
assigns
[
'ran_filter'
].
join
(
' '
)
end
def
test_first_
filter_in_multiple_before_filter
_chain_halts
def
test_first_
action_in_multiple_before_action
_chain_halts
controller
=
::
FilterTest
::
TestMultipleFiltersController
.
new
response
=
test_process
(
controller
,
'fail_1'
)
assert_equal
' '
,
response
.
body
assert_equal
1
,
controller
.
instance_variable_get
(
:@try
)
end
def
test_second_
filter_in_multiple_before_filter
_chain_halts
def
test_second_
action_in_multiple_before_action
_chain_halts
controller
=
::
FilterTest
::
TestMultipleFiltersController
.
new
response
=
test_process
(
controller
,
'fail_2'
)
assert_equal
' '
,
response
.
body
assert_equal
2
,
controller
.
instance_variable_get
(
:@try
)
end
def
test_last_
filter_in_multiple_before_filter
_chain_halts
def
test_last_
action_in_multiple_before_action
_chain_halts
controller
=
::
FilterTest
::
TestMultipleFiltersController
.
new
response
=
test_process
(
controller
,
'fail_3'
)
assert_equal
' '
,
response
.
body
...
...
actionpack/test/controller/test_case_test.rb
浏览文件 @
6c5f43ba
...
...
@@ -164,7 +164,7 @@ def view_assigns
end
class
DefaultUrlOptionsCachingController
<
ActionController
::
Base
before_
filter
{
@dynamic_opt
=
'opt'
}
before_
action
{
@dynamic_opt
=
'opt'
}
def
test_url_options_reset
render
text:
url_for
(
params
)
...
...
railties/lib/rails/info_controller.rb
浏览文件 @
6c5f43ba
...
...
@@ -5,7 +5,7 @@ class Rails::InfoController < Rails::ApplicationController # :nodoc:
prepend_view_path
ActionDispatch
::
DebugExceptions
::
RESCUES_TEMPLATE_PATH
layout
->
{
request
.
xhr?
?
false
:
'application'
}
before_
filter
:require_local!
before_
action
:require_local!
def
index
redirect_to
action: :routes
...
...
railties/lib/rails/mailers_controller.rb
浏览文件 @
6c5f43ba
...
...
@@ -3,8 +3,8 @@
class
Rails::MailersController
<
Rails
::
ApplicationController
# :nodoc:
prepend_view_path
ActionDispatch
::
DebugExceptions
::
RESCUES_TEMPLATE_PATH
before_
filter
:require_local!
before_
filter
:find_preview
,
only: :preview
before_
action
:require_local!
before_
action
:find_preview
,
only: :preview
def
index
@previews
=
ActionMailer
::
Preview
.
all
...
...
@@ -70,4 +70,4 @@ def find_part(format)
@email
end
end
end
\ No newline at end of file
end
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录