From e4ea43b2b85ad5f3115f00220601eb719705139a Mon Sep 17 00:00:00 2001 From: GitLab Bot Date: Mon, 27 Jan 2020 21:08:47 +0000 Subject: Add latest changes from gitlab-org/gitlab@master --- app/mailers/abuse_report_mailer.rb | 2 +- app/mailers/application_mailer.rb | 36 ++++++++++++++++++++++++++++++++++ app/mailers/base_mailer.rb | 36 ---------------------------------- app/mailers/email_rejection_mailer.rb | 2 +- app/mailers/notify.rb | 2 +- app/mailers/repository_check_mailer.rb | 2 +- 6 files changed, 40 insertions(+), 40 deletions(-) create mode 100644 app/mailers/application_mailer.rb delete mode 100644 app/mailers/base_mailer.rb (limited to 'app/mailers') diff --git a/app/mailers/abuse_report_mailer.rb b/app/mailers/abuse_report_mailer.rb index e0aa66e6de3..0f2f63b43f5 100644 --- a/app/mailers/abuse_report_mailer.rb +++ b/app/mailers/abuse_report_mailer.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class AbuseReportMailer < BaseMailer +class AbuseReportMailer < ApplicationMailer layout 'empty_mailer' helper EmailsHelper diff --git a/app/mailers/application_mailer.rb b/app/mailers/application_mailer.rb new file mode 100644 index 00000000000..e0c95370072 --- /dev/null +++ b/app/mailers/application_mailer.rb @@ -0,0 +1,36 @@ +# frozen_string_literal: true + +class ApplicationMailer < ActionMailer::Base + around_action :render_with_default_locale + + helper ApplicationHelper + helper MarkupHelper + + attr_accessor :current_user + helper_method :current_user, :can? + + default from: proc { default_sender_address.format } + default reply_to: proc { default_reply_to_address.format } + + def can? + Ability.allowed?(current_user, action, subject) + end + + 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 + address + end + + def default_reply_to_address + address = Mail::Address.new(Gitlab.config.gitlab.email_reply_to) + address.display_name = Gitlab.config.gitlab.email_display_name + address + end +end diff --git a/app/mailers/base_mailer.rb b/app/mailers/base_mailer.rb deleted file mode 100644 index 5fd209c4761..00000000000 --- a/app/mailers/base_mailer.rb +++ /dev/null @@ -1,36 +0,0 @@ -# frozen_string_literal: true - -class BaseMailer < ActionMailer::Base - around_action :render_with_default_locale - - helper ApplicationHelper - helper MarkupHelper - - attr_accessor :current_user - helper_method :current_user, :can? - - default from: proc { default_sender_address.format } - default reply_to: proc { default_reply_to_address.format } - - def can? - Ability.allowed?(current_user, action, subject) - end - - 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 - address - end - - def default_reply_to_address - address = Mail::Address.new(Gitlab.config.gitlab.email_reply_to) - address.display_name = Gitlab.config.gitlab.email_display_name - address - end -end diff --git a/app/mailers/email_rejection_mailer.rb b/app/mailers/email_rejection_mailer.rb index d743533b1bc..25721658285 100644 --- a/app/mailers/email_rejection_mailer.rb +++ b/app/mailers/email_rejection_mailer.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class EmailRejectionMailer < BaseMailer +class EmailRejectionMailer < ApplicationMailer layout 'empty_mailer' helper EmailsHelper diff --git a/app/mailers/notify.rb b/app/mailers/notify.rb index 92939136de2..49eacc44519 100644 --- a/app/mailers/notify.rb +++ b/app/mailers/notify.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class Notify < BaseMailer +class Notify < ApplicationMailer include ActionDispatch::Routing::PolymorphicRoutes include GitlabRoutingHelper include EmailsHelper diff --git a/app/mailers/repository_check_mailer.rb b/app/mailers/repository_check_mailer.rb index aa56ba1828b..b8f990f26c8 100644 --- a/app/mailers/repository_check_mailer.rb +++ b/app/mailers/repository_check_mailer.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class RepositoryCheckMailer < BaseMailer +class RepositoryCheckMailer < ApplicationMailer # rubocop: disable CodeReuse/ActiveRecord layout 'empty_mailer' -- cgit v1.2.3