未验证 提交 19df75dc 编写于 作者: R Rafael França 提交者: GitHub

Merge pull request #35997 from...

Merge pull request #35997 from tjoyal/Rails/MailersController/do-not-leak-I18n-global-setting-changes

[Rails::MailersController] Do not leak I18n global setting changes
......@@ -5,8 +5,9 @@
class Rails::MailersController < Rails::ApplicationController # :nodoc:
prepend_view_path ActionDispatch::DebugView::RESCUES_TEMPLATE_PATH
around_action :set_locale, only: :preview
before_action :find_preview, only: :preview
before_action :require_local!, unless: :show_previews?
before_action :find_preview, :set_locale, only: :preview
helper_method :part_query, :locale_query
......@@ -92,6 +93,8 @@ def locale_query(locale)
end
def set_locale
I18n.locale = params[:locale] || I18n.default_locale
I18n.with_locale(params[:locale] || I18n.default_locale) do
yield
end
end
end
......@@ -515,6 +515,13 @@ def foo
assert_match '<option selected value="locale=ja">ja', last_response.body
end
test "preview does not leak I18n global setting changes" do
I18n.with_locale(:en) do
get "/rails/mailers/notifier/foo.txt?locale=ja"
assert_equal :en, I18n.locale
end
end
test "mailer previews create correct links when loaded on a subdirectory" do
mailer "notifier", <<-RUBY
class Notifier < ActionMailer::Base
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册