A platform for community discussion. Free, open, simple.
FIX: customized email subjects was ignored for some notifications
Neil Lalonde34f564acd657
diff --git a/lib/email/message_builder.rb b/lib/email/message_builder.rbindex df76f9170c6..4dafa6bbf95 100644--- a/lib/email/message_builder.rb+++ b/lib/email/message_builder.rb@@ -51,7 +51,10 @@ module Emailenddef subject- if @opts[:use_site_subject]+ if @opts[:template] &&+ TranslationOverride.exists?(locale: I18n.locale, translation_key: "#{@opts[:template]}.subject_template")+ subject = I18n.t("#{@opts[:template]}.subject_template", @template_args)+ elsif @opts[:use_site_subject]subject = String.new(SiteSetting.email_subject)subject.gsub!("%{site_name}", @template_args[:email_prefix])subject.gsub!("%{optional_re}", @opts[:add_re_to_subject] ? I18n.t('subject_re') : '')diff --git a/spec/components/email/message_builder_spec.rb b/spec/components/email/message_builder_spec.rbindex 57f055f3512..939257d201b 100644--- a/spec/components/email/message_builder_spec.rb+++ b/spec/components/email/message_builder_spec.rb@@ -257,6 +257,20 @@ describe Email::MessageBuilder doexpect(templated_builder.subject).to eq(rendered_template)end+ context "when use_site_subject is true" do+ let(:templated_builder) { Email::MessageBuilder.new(to_address, template: 'mystery', use_site_subject: true) }++ it "can use subject override" do+ override = TranslationOverride.create(+ locale: I18n.locale,+ translation_key: "mystery.subject_template",+ value: "my customized subject"+ )+ I18n.expects(:t).with("mystery.subject_template", templated_builder.template_args).returns(override.value)+ expect(templated_builder.subject).to eq(override.value)+ end+ end+endcontext "from field" do