FIX: Failed to save email template with pluralized subject
This commit is contained in:
parent
5cf63e43c6
commit
4000978452
|
@ -113,12 +113,15 @@ class Admin::EmailTemplatesController < Admin::AdminController
|
||||||
|
|
||||||
def update_key(key, value)
|
def update_key(key, value)
|
||||||
old_value = I18n.t(key)
|
old_value = I18n.t(key)
|
||||||
|
|
||||||
|
unless old_value.is_a?(Hash)
|
||||||
translation_override = TranslationOverride.upsert!(I18n.locale, key, value)
|
translation_override = TranslationOverride.upsert!(I18n.locale, key, value)
|
||||||
|
end
|
||||||
|
|
||||||
{
|
{
|
||||||
key: key,
|
key: key,
|
||||||
old_value: old_value,
|
old_value: old_value,
|
||||||
error_messages: translation_override.errors.full_messages
|
error_messages: translation_override&.errors&.full_messages
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -214,6 +214,21 @@ RSpec.describe Admin::EmailTemplatesController do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context "when subject has plural keys" do
|
||||||
|
it "doesn't update the subject" do
|
||||||
|
old_subject = I18n.t('system_messages.pending_users_reminder.subject_template')
|
||||||
|
expect(old_subject).to be_a(Hash)
|
||||||
|
|
||||||
|
put '/admin/customize/email_templates/system_messages.pending_users_reminder', params: {
|
||||||
|
email_template: { subject: '', body: 'Lorem ipsum' }
|
||||||
|
}, headers: headers
|
||||||
|
|
||||||
|
expect(response.status).to eq(200)
|
||||||
|
|
||||||
|
expect(I18n.t('system_messages.pending_users_reminder.subject_template')).to eq(old_subject)
|
||||||
|
expect(I18n.t('system_messages.pending_users_reminder.text_body_template')).to eq('Lorem ipsum')
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue