diff options
author | Lin Jen-Shin <godfat@godfat.org> | 2018-12-21 11:24:08 +0000 |
---|---|---|
committer | Lin Jen-Shin <godfat@godfat.org> | 2018-12-21 11:24:08 +0000 |
commit | 1567f17941df86164fcf0c39e0be5771b15f6b97 (patch) | |
tree | db6a6460915a79c1e2eed3e1c76bdbab06e212fa | |
parent | 3a401448d7027849520985980907787ea21d7243 (diff) | |
parent | a412bcff45ca64d1035a8c6583dceab4d9598508 (diff) | |
download | gitlab-ce-1567f17941df86164fcf0c39e0be5771b15f6b97.tar.gz |
Merge branch '53933-include-dates-in-milestone-change-email' into 'master'
Add date range to milestone changed emails
Closes #53933
See merge request gitlab-org/gitlab-ce!23762
-rw-r--r-- | app/mailers/emails/issues.rb | 4 | ||||
-rw-r--r-- | app/mailers/emails/merge_requests.rb | 4 | ||||
-rw-r--r-- | app/mailers/notify.rb | 1 | ||||
-rw-r--r-- | app/views/notify/changed_milestone_email.html.haml (renamed from app/views/notify/changed_milestone_issue_email.html.haml) | 2 | ||||
-rw-r--r-- | app/views/notify/changed_milestone_email.text.erb | 1 | ||||
-rw-r--r-- | app/views/notify/changed_milestone_issue_email.text.erb | 1 | ||||
-rw-r--r-- | app/views/notify/changed_milestone_merge_request_email.html.haml | 3 | ||||
-rw-r--r-- | app/views/notify/changed_milestone_merge_request_email.text.erb | 1 | ||||
-rw-r--r-- | changelogs/unreleased/53933-include-dates-in-milestone-change-email.yml | 5 | ||||
-rw-r--r-- | spec/views/notify/changed_milestone_email.html.haml_spec.rb | 35 |
10 files changed, 50 insertions, 7 deletions
diff --git a/app/mailers/emails/issues.rb b/app/mailers/emails/issues.rb index 93b51fb1774..370e6d2f90b 100644 --- a/app/mailers/emails/issues.rb +++ b/app/mailers/emails/issues.rb @@ -56,7 +56,9 @@ module Emails @milestone = milestone @milestone_url = milestone_url(@milestone) - mail_answer_thread(@issue, issue_thread_options(updated_by_user_id, recipient_id, reason)) + mail_answer_thread(@issue, issue_thread_options(updated_by_user_id, recipient_id, reason).merge({ + template_name: 'changed_milestone_email' + })) end def issue_status_changed_email(recipient_id, issue_id, status, updated_by_user_id, reason = nil) diff --git a/app/mailers/emails/merge_requests.rb b/app/mailers/emails/merge_requests.rb index 6524d0c2087..9ba8f92fcbf 100644 --- a/app/mailers/emails/merge_requests.rb +++ b/app/mailers/emails/merge_requests.rb @@ -51,7 +51,9 @@ module Emails @milestone = milestone @milestone_url = milestone_url(@milestone) - mail_answer_thread(@merge_request, merge_request_thread_options(updated_by_user_id, recipient_id, reason)) + mail_answer_thread(@merge_request, merge_request_thread_options(updated_by_user_id, recipient_id, reason).merge({ + template_name: 'changed_milestone_email' + })) end def closed_merge_request_email(recipient_id, merge_request_id, updated_by_user_id, reason = nil) diff --git a/app/mailers/notify.rb b/app/mailers/notify.rb index 15710bee4d4..efa1233b434 100644 --- a/app/mailers/notify.rb +++ b/app/mailers/notify.rb @@ -16,6 +16,7 @@ class Notify < BaseMailer include Emails::AutoDevops include Emails::RemoteMirrors + helper MilestonesHelper helper MergeRequestsHelper helper DiffHelper helper BlobHelper diff --git a/app/views/notify/changed_milestone_issue_email.html.haml b/app/views/notify/changed_milestone_email.html.haml index 7d5425fc72d..01d27cac36b 100644 --- a/app/views/notify/changed_milestone_issue_email.html.haml +++ b/app/views/notify/changed_milestone_email.html.haml @@ -1,3 +1,5 @@ %p Milestone changed to %strong= link_to(@milestone.name, @milestone_url) + - if date_range = milestone_date_range(@milestone) + = "(#{date_range})" diff --git a/app/views/notify/changed_milestone_email.text.erb b/app/views/notify/changed_milestone_email.text.erb new file mode 100644 index 00000000000..a466da4eb19 --- /dev/null +++ b/app/views/notify/changed_milestone_email.text.erb @@ -0,0 +1 @@ +Milestone changed to <%= @milestone.name %><% if date_range = milestone_date_range(@milestone) %> (<%= date_range %>)<% end %> ( <%= @milestone_url %> ) diff --git a/app/views/notify/changed_milestone_issue_email.text.erb b/app/views/notify/changed_milestone_issue_email.text.erb deleted file mode 100644 index c5fc0b61518..00000000000 --- a/app/views/notify/changed_milestone_issue_email.text.erb +++ /dev/null @@ -1 +0,0 @@ -Milestone changed to <%= @milestone.name %> ( <%= @milestone_url %> ) diff --git a/app/views/notify/changed_milestone_merge_request_email.html.haml b/app/views/notify/changed_milestone_merge_request_email.html.haml deleted file mode 100644 index 7d5425fc72d..00000000000 --- a/app/views/notify/changed_milestone_merge_request_email.html.haml +++ /dev/null @@ -1,3 +0,0 @@ -%p - Milestone changed to - %strong= link_to(@milestone.name, @milestone_url) diff --git a/app/views/notify/changed_milestone_merge_request_email.text.erb b/app/views/notify/changed_milestone_merge_request_email.text.erb deleted file mode 100644 index c5fc0b61518..00000000000 --- a/app/views/notify/changed_milestone_merge_request_email.text.erb +++ /dev/null @@ -1 +0,0 @@ -Milestone changed to <%= @milestone.name %> ( <%= @milestone_url %> ) diff --git a/changelogs/unreleased/53933-include-dates-in-milestone-change-email.yml b/changelogs/unreleased/53933-include-dates-in-milestone-change-email.yml new file mode 100644 index 00000000000..5c40a1e900c --- /dev/null +++ b/changelogs/unreleased/53933-include-dates-in-milestone-change-email.yml @@ -0,0 +1,5 @@ +--- +title: Add date range in milestone change email notifications +merge_request: 23762 +author: +type: changed diff --git a/spec/views/notify/changed_milestone_email.html.haml_spec.rb b/spec/views/notify/changed_milestone_email.html.haml_spec.rb new file mode 100644 index 00000000000..194b58840a3 --- /dev/null +++ b/spec/views/notify/changed_milestone_email.html.haml_spec.rb @@ -0,0 +1,35 @@ +# frozen_string_literal: true + +require 'spec_helper' + +describe 'notify/changed_milestone_email.html.haml' do + let(:milestone) { create(:milestone, title: 'some-milestone') } + let(:milestone_link) { milestone_url(milestone) } + + before do + assign(:milestone, milestone) + assign(:milestone_url, milestone_link) + end + + context 'milestone without start and due dates' do + it 'renders without date range' do + render + + expect(rendered).to have_content('Milestone changed to some-milestone', exact: true) + expect(rendered).to have_link('some-milestone', href: milestone_link) + end + end + + context 'milestone with start and due dates' do + before do + milestone.update(start_date: '2018-01-01', due_date: '2018-12-31') + end + + it 'renders with date range' do + render + + expect(rendered).to have_content('Milestone changed to some-milestone (Jan 1, 2018–Dec 31, 2018)', exact: true) + expect(rendered).to have_link('some-milestone', href: milestone_link) + end + end +end |