Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
rails
提交
262b2ea8
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,发现更多精彩内容 >>
提交
262b2ea8
编写于
1月 19, 2011
作者:
J
José Valim
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Solve SystemStackError when changing locale inside ActionMailer [#5329 state:resolved]
上级
b247f394
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
14 addition
and
17 deletion
+14
-17
actionmailer/test/i18n_with_controller_test.rb
actionmailer/test/i18n_with_controller_test.rb
+6
-10
actionpack/lib/abstract_controller/rendering.rb
actionpack/lib/abstract_controller/rendering.rb
+5
-4
actionpack/lib/action_view/lookup_context.rb
actionpack/lib/action_view/lookup_context.rb
+2
-2
actionpack/test/template/lookup_context_test.rb
actionpack/test/template/lookup_context_test.rb
+1
-1
未找到文件。
actionmailer/test/i18n_with_controller_test.rb
浏览文件 @
262b2ea8
...
...
@@ -2,13 +2,12 @@
require
'action_controller'
class
I18nTestMailer
<
ActionMailer
::
Base
configure
do
|
c
|
c
.
assets_dir
=
''
# To get the tests to pass
c
.
assets_dir
=
''
end
def
mail_with_i18n_subject
(
recipient
)
@recipient
=
recipient
@recipient
=
recipient
I18n
.
locale
=
:de
mail
(
:to
=>
recipient
,
:subject
=>
"
#{
I18n
.
t
:email_subject
}
#{
recipient
}
"
,
:from
=>
"system@loudthinking.com"
,
:date
=>
Time
.
local
(
2004
,
12
,
12
))
...
...
@@ -17,13 +16,12 @@ def mail_with_i18n_subject(recipient)
class
TestController
<
ActionController
::
Base
def
send_mail
I18nTestMailer
.
mail_with_i18n_subject
(
@recipient
).
deliver
I18nTestMailer
.
mail_with_i18n_subject
(
"test@localhost"
).
deliver
render
:text
=>
'Mail sent'
end
end
class
ActionMailerI18nWithControllerTest
<
ActionDispatch
::
IntegrationTest
Routes
=
ActionDispatch
::
Routing
::
RouteSet
.
new
Routes
.
draw
do
match
':controller(/:action(/:id))'
...
...
@@ -35,12 +33,10 @@ def app
def
setup
I18n
.
backend
.
store_translations
(
'de'
,
:email_subject
=>
'[Signed up] Welcome'
)
set_delivery_method
:test
ActionMailer
::
Base
.
perform_deliveries
=
true
ActionMailer
::
Base
.
deliveries
.
clear
ActiveSupport
::
Deprecation
.
silenced
=
false
end
@recipient
=
'test@localhost'
def
teardown
I18n
.
locale
=
:en
end
def
test_send_mail
...
...
actionpack/lib/abstract_controller/rendering.rb
浏览文件 @
262b2ea8
...
...
@@ -13,14 +13,15 @@ def initialize(message = nil)
# This is a class to fix I18n global state. Whenever you provide I18n.locale during a request,
# it will trigger the lookup_context and consequently expire the cache.
class
I18nProxy
<
::
I18n
::
Config
#:nodoc:
attr_reader
:
i18n
_config
,
:lookup_context
attr_reader
:
original
_config
,
:lookup_context
def
initialize
(
i18n_config
,
lookup_context
)
@i18n_config
,
@lookup_context
=
i18n_config
,
lookup_context
def
initialize
(
original_config
,
lookup_context
)
original_config
=
original_config
.
original_config
if
original_config
.
respond_to?
(
:original_config
)
@original_config
,
@lookup_context
=
original_config
,
lookup_context
end
def
locale
@
i18n
_config
.
locale
@
original
_config
.
locale
end
def
locale
=
(
value
)
...
...
actionpack/lib/action_view/lookup_context.rb
浏览文件 @
262b2ea8
...
...
@@ -186,11 +186,11 @@ def locale
end
# Overload locale= to also set the I18n.locale. If the current I18n.config object responds
# to
i18n
_config, it means that it's has a copy of the original I18n configuration and it's
# to
original
_config, it means that it's has a copy of the original I18n configuration and it's
# acting as proxy, which we need to skip.
def
locale
=
(
value
)
if
value
config
=
I18n
.
config
.
respond_to?
(
:
i18n_config
)
?
I18n
.
config
.
i18n
_config
:
I18n
.
config
config
=
I18n
.
config
.
respond_to?
(
:
original_config
)
?
I18n
.
config
.
original
_config
:
I18n
.
config
config
.
locale
=
value
end
...
...
actionpack/test/template/lookup_context_test.rb
浏览文件 @
262b2ea8
...
...
@@ -73,7 +73,7 @@ def teardown
assert_equal
:pt
,
I18n
.
locale
assert_equal
:pt
,
@lookup_context
.
locale
ensure
I18n
.
config
=
I18n
.
config
.
i18n
_config
I18n
.
config
=
I18n
.
config
.
original
_config
end
assert_equal
:pt
,
I18n
.
locale
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录