summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorRuben Davila <rdavila84@gmail.com>2017-05-25 10:22:45 -0500
committerRuben Davila <rdavila84@gmail.com>2017-05-25 10:22:45 -0500
commit5c921809cd86e1031a6a5075da142fef3bb01d6d (patch)
tree0c04cf9d24f9e94c2bf5dfd709c22f142bec5e77 /app
parentd07e85e1033f8026f155c6171cb3ebcd6b93d9ed (diff)
downloadgitlab-ce-5c921809cd86e1031a6a5075da142fef3bb01d6d.tar.gz
Bugfix: Always use the default language when generating emails.32748-emails-are-being-sent-with-the-wrong-language
There was a race condition issue when the application was generating an email and was using a language that was previously being used in other request.
Diffstat (limited to 'app')
-rw-r--r--app/controllers/application_controller.rb8
-rw-r--r--app/mailers/base_mailer.rb6
2 files changed, 8 insertions, 6 deletions
diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb
index 8ce9150e4a9..2c43ebe0a5a 100644
--- a/app/controllers/application_controller.rb
+++ b/app/controllers/application_controller.rb
@@ -275,11 +275,7 @@ class ApplicationController < ActionController::Base
request.base_url
end
- def set_locale
- Gitlab::I18n.set_locale(current_user)
-
- yield
- ensure
- Gitlab::I18n.reset_locale
+ def set_locale(&block)
+ Gitlab::I18n.with_user_locale(current_user, &block)
end
end
diff --git a/app/mailers/base_mailer.rb b/app/mailers/base_mailer.rb
index d2980db218a..654468bc7fe 100644
--- a/app/mailers/base_mailer.rb
+++ b/app/mailers/base_mailer.rb
@@ -1,4 +1,6 @@
class BaseMailer < ActionMailer::Base
+ around_action :render_with_default_locale
+
helper ApplicationHelper
helper MarkupHelper
@@ -14,6 +16,10 @@ class BaseMailer < ActionMailer::Base
private
+ def render_with_default_locale(&block)
+ Gitlab::I18n.with_default_locale(&block)
+ end
+
def default_sender_address
address = Mail::Address.new(Gitlab.config.gitlab.email_from)
address.display_name = Gitlab.config.gitlab.email_display_name