Commit 91fb24fc authored by Sincheol (David) Kim's avatar Sincheol (David) Kim

Merge branch '350318-update-iteration-changed-notification-to-include-cadence' into 'master'

Update iteration changed notification message

See merge request gitlab-org/gitlab!78250
parents 51052afc 79f89989
...@@ -149,6 +149,12 @@ module EE ...@@ -149,6 +149,12 @@ module EE
end end
end end
def display_text
return period unless group.iteration_cadences_feature_flag_enabled?
"#{iterations_cadence.title} #{period}"
end
def state def state
STATE_ENUM_MAP.key(state_enum) STATE_ENUM_MAP.key(state_enum)
end end
...@@ -295,5 +301,9 @@ module EE ...@@ -295,5 +301,9 @@ module EE
errors.add(:title, _('already being used for another iteration within this cadence.')) if title_exists errors.add(:title, _('already being used for another iteration within this cadence.')) if title_exists
end end
def period
"#{start_date.to_s(:medium)} - #{due_date.to_s(:medium)}"
end
end end
end end
%p %p
= _('Iteration changed to') = _('Iteration changed to')
%strong= link_to(@iteration.name, @iteration_url) %strong= link_to(@iteration.display_text, @iteration_url)
- if date_range = timebox_date_range(@iteration) = "(#{@iteration.title})"
= "(#{date_range})"
<%= _('Iteration changed to') %> <%= @iteration.name %><% if date_range = timebox_date_range(@iteration) %> (<%= date_range %>)<% end %> ( <%= @iteration_url %> ) <%= _('Iteration changed to') %> <%= @iteration.display_text %> (<%= @iteration.title %>) ( <%= @iteration_url %> )
...@@ -12,14 +12,31 @@ RSpec.describe Emails::Issues do ...@@ -12,14 +12,31 @@ RSpec.describe Emails::Issues do
let_it_be(:issue) { create(:issue, project: project) } let_it_be(:issue) { create(:issue, project: project) }
context 'iterations' do context 'iterations' do
let_it_be(:iteration) { create(:iteration, group: group) } let_it_be(:iterations_cadence) { create(:iterations_cadence, title: "Plan cadence", group: group) }
let_it_be(:iteration) { create(:iteration, iterations_cadence: iterations_cadence, start_date: Date.new(2022, 9, 30), due_date: Date.new(2022, 10, 4)) }
describe '#changed_iteration_issue_email' do describe '#changed_iteration_issue_email', :aggregate_failures do
subject { Notify.changed_iteration_issue_email(user.id, issue.id, iteration, user.id) } subject { Notify.changed_iteration_issue_email(user.id, issue.id, iteration, user.id) }
before do
stub_feature_flags(iteration_cadences: false)
end
it 'shows the iteration it was changed to' do it 'shows the iteration it was changed to' do
expect(subject).to have_body_text 'Iteration changed to' expect(subject).to have_body_text 'Iteration changed to'
expect(subject).to have_body_text 'Sep 30, 2022 - Oct 4, 2022'
expect(subject).to have_body_text iteration.name expect(subject).to have_body_text iteration.name
expect(subject).not_to have_body_text 'Plan cadence'
end
context 'when iteration_cadences FF enabled' do
before do
stub_feature_flags(iteration_cadences: true)
end
it 'shows the iteration it was changed to' do
expect(subject).to have_body_text 'Plan cadence Sep 30, 2022 - Oct 4, 2022'
end
end end
end end
......
...@@ -40,6 +40,28 @@ RSpec.describe Iteration do ...@@ -40,6 +40,28 @@ RSpec.describe Iteration do
end end
end end
describe '#display_text' do
let_it_be(:group) { create(:group) }
let_it_be(:iterations_cadence) { create(:iterations_cadence, title: "Plan cadence", group: group) }
let_it_be(:iteration) { create(:iteration, iterations_cadence: iterations_cadence, start_date: Date.new(2022, 9, 30), due_date: Date.new(2022, 10, 4)) }
subject { iteration.display_text }
before do
stub_feature_flags(iteration_cadences: false)
end
it { is_expected.to eq('Sep 30, 2022 - Oct 4, 2022') }
context 'when iteration_cadences FF enabled' do
before do
stub_feature_flags(iteration_cadences: true)
end
it { is_expected.to eq('Plan cadence Sep 30, 2022 - Oct 4, 2022') }
end
end
describe '.reference_pattern' do describe '.reference_pattern' do
let_it_be(:group) { create(:group) } let_it_be(:group) { create(:group) }
let_it_be(:iteration_cadence) { create(:iterations_cadence, group: group) } let_it_be(:iteration_cadence) { create(:iterations_cadence, group: group) }
......
...@@ -441,7 +441,7 @@ RSpec.describe EE::NotificationService, :mailer do ...@@ -441,7 +441,7 @@ RSpec.describe EE::NotificationService, :mailer do
let(:guest) { create(:user) } let(:guest) { create(:user) }
let(:admin) { create(:admin) } let(:admin) { create(:admin) }
let(:confidential_issue) { create(:issue, :confidential, project: project, title: 'Confidential issue', author: author, assignees: [assignee]) } let(:confidential_issue) { create(:issue, :confidential, project: project, title: 'Confidential issue', author: author, assignees: [assignee]) }
let(:iteration) { create(:iteration, :skip_project_validation, project: project, issues: [confidential_issue]) } let(:iteration) { create(:iteration, :skip_project_validation, group: group, issues: [confidential_issue]) }
it "emails subscribers of the issue's iteration that can read the issue" do it "emails subscribers of the issue's iteration that can read the issue" do
project.add_developer(member) project.add_developer(member)
...@@ -472,7 +472,7 @@ RSpec.describe EE::NotificationService, :mailer do ...@@ -472,7 +472,7 @@ RSpec.describe EE::NotificationService, :mailer do
let(:mailer_method) { :changed_iteration_issue_email } let(:mailer_method) { :changed_iteration_issue_email }
context do context do
let(:new_iteration) { create(:iteration, :skip_project_validation, project: project, issues: [issue]) } let(:new_iteration) { create(:iteration, :skip_project_validation, group: group, issues: [issue]) }
let!(:subscriber_to_new_iteration) { create(:user) { |u| issue.toggle_subscription(u, project) } } let!(:subscriber_to_new_iteration) { create(:user) { |u| issue.toggle_subscription(u, project) } }
it_behaves_like 'altered iteration notification on issue' do it_behaves_like 'altered iteration notification on issue' do
...@@ -495,7 +495,7 @@ RSpec.describe EE::NotificationService, :mailer do ...@@ -495,7 +495,7 @@ RSpec.describe EE::NotificationService, :mailer do
let(:guest) { create(:user) } let(:guest) { create(:user) }
let(:admin) { create(:admin) } let(:admin) { create(:admin) }
let(:confidential_issue) { create(:issue, :confidential, project: project, title: 'Confidential issue', author: author, assignees: [assignee]) } let(:confidential_issue) { create(:issue, :confidential, project: project, title: 'Confidential issue', author: author, assignees: [assignee]) }
let(:new_iteration) { create(:iteration, :skip_project_validation, project: project, issues: [confidential_issue]) } let(:new_iteration) { create(:iteration, :skip_project_validation, group: group, issues: [confidential_issue]) }
it "emails subscribers of the issue's iteration that can read the issue" do it "emails subscribers of the issue's iteration that can read the issue" do
project.add_developer(member) project.add_developer(member)
......
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