Commit 48707d21 authored by David Kim's avatar David Kim Committed by James Lopez

Fix notification_event_name for dynamic email events

Also, adds missing i18n entries that needs to be translated.
parent 4454cd3e
......@@ -106,7 +106,8 @@ module NotificationsHelper
when :success_pipeline
s_('NotificationEvent|Successful pipeline')
else
s_(event.to_s.humanize)
event_name = "NotificationEvent|#{event.to_s.humanize}"
s_(event_name)
end
end
......
......@@ -30,6 +30,7 @@ class NotificationSetting < ApplicationRecord
scope :preload_source_route, -> { preload(source: [:route]) }
# NOTE: Applicable unfound_translations.rb also needs to be updated when below events are changed.
EMAIL_EVENTS = [
:new_release,
:new_note,
......@@ -51,7 +52,6 @@ class NotificationSetting < ApplicationRecord
:moved_project
].freeze
# Update unfound_translations.rb when events are changed
def self.email_events(source = nil)
EMAIL_EVENTS
end
......
......@@ -18847,9 +18847,15 @@ msgstr ""
msgid "NotificationEvent|Fixed pipeline"
msgstr ""
msgid "NotificationEvent|Issue due"
msgstr ""
msgid "NotificationEvent|Merge merge request"
msgstr ""
msgid "NotificationEvent|Moved project"
msgstr ""
msgid "NotificationEvent|New epic"
msgstr ""
......@@ -18865,6 +18871,9 @@ msgstr ""
msgid "NotificationEvent|New release"
msgstr ""
msgid "NotificationEvent|Push to merge request"
msgstr ""
msgid "NotificationEvent|Reassign issue"
msgstr ""
......@@ -18874,6 +18883,9 @@ msgstr ""
msgid "NotificationEvent|Reopen issue"
msgstr ""
msgid "NotificationEvent|Reopen merge request"
msgstr ""
msgid "NotificationEvent|Successful pipeline"
msgstr ""
......
......@@ -4,16 +4,20 @@
# https://github.com/grosser/gettext_i18n_rails#unfound-translations-with-rake-gettextfind
# NotificationSetting.email_events
N_('NotificationEvent|New release')
N_('NotificationEvent|New note')
N_('NotificationEvent|New issue')
N_('NotificationEvent|Reopen issue')
N_('NotificationEvent|Close issue')
N_('NotificationEvent|Reassign issue')
N_('NotificationEvent|Issue due')
N_('NotificationEvent|New merge request')
N_('NotificationEvent|Push to merge request')
N_('NotificationEvent|Reopen merge request')
N_('NotificationEvent|Close merge request')
N_('NotificationEvent|Reassign merge request')
N_('NotificationEvent|Change reviewer merge request')
N_('NotificationEvent|Merge merge request')
N_('NotificationEvent|Failed pipeline')
N_('NotificationEvent|Fixed pipeline')
N_('NotificationEvent|New release')
N_('NotificationEvent|Change reviewer merge request')
N_('NotificationEvent|Moved project')
......@@ -20,10 +20,19 @@ RSpec.describe NotificationsHelper do
end
describe '#notification_event_name' do
it { expect(notification_event_name(:success_pipeline)).to match('Successful pipeline') }
it { expect(notification_event_name(:failed_pipeline)).to match('Failed pipeline') }
it { expect(notification_event_name(:fixed_pipeline)).to match('Fixed pipeline') }
it { expect(notification_event_name(:moved_project)).to match('Moved project') }
context 'for success_pipeline' do
it 'returns the custom name' do
expect(FastGettext).to receive(:cached_find).with('NotificationEvent|Successful pipeline')
expect(notification_event_name(:success_pipeline)).to eq('Successful pipeline')
end
end
context 'for everything else' do
it 'returns a humanized name' do
expect(FastGettext).to receive(:cached_find).with('NotificationEvent|Failed pipeline')
expect(notification_event_name(:failed_pipeline)).to eq('Failed pipeline')
end
end
end
describe '#notification_icon_level' do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment