FIX: customized email subjects was ignored for some notifications
Email templates for notifications about new posts and topics weren't using customized values.
This commit is contained in:
parent
2ee6a615b7
commit
34f564acd6
|
@ -51,7 +51,10 @@ module Email
|
|||
end
|
||||
|
||||
def 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') : '')
|
||||
|
|
|
@ -257,6 +257,20 @@ describe Email::MessageBuilder do
|
|||
expect(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
|
||||
|
||||
end
|
||||
|
||||
context "from field" do
|
||||
|
|
Loading…
Reference in New Issue