Commit 79f89989 authored by Eulyeon Ko's avatar Eulyeon Ko Committed by Sincheol (David) Kim

Update iteration changed notification format

- Iteration period (start and due dates) should be the link/main text
- Iteration title will be made optional and should be wrapped in a
  parenthesis for display.
- Iteration cadence name should be displayed when the FF is turned on.
- Remove project iteration from notification spec.
   Project iteration has been abandoned. Iteration will always be scoped to groups.

Changelog: changed
EE: true
parent c47b7c9d
......@@ -149,6 +149,12 @@ module EE
end
end
def display_text
return period unless group.iteration_cadences_feature_flag_enabled?
"#{iterations_cadence.title} #{period}"
end
def state
STATE_ENUM_MAP.key(state_enum)
end
......@@ -295,5 +301,9 @@ module EE
errors.add(:title, _('already being used for another iteration within this cadence.')) if title_exists
end
def period
"#{start_date.to_s(:medium)} - #{due_date.to_s(:medium)}"
end
end
end
%p
= _('Iteration changed to')
%strong= link_to(@iteration.name, @iteration_url)
- if date_range = timebox_date_range(@iteration)
= "(#{date_range})"
%strong= link_to(@iteration.display_text, @iteration_url)
= "(#{@iteration.title})"
<%= _('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
let_it_be(:issue) { create(:issue, project: project) }
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) }
before do
stub_feature_flags(iteration_cadences: false)
end
it 'shows the iteration it was changed to' do
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).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
......
......@@ -40,6 +40,28 @@ RSpec.describe Iteration do
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
let_it_be(:group) { create(:group) }
let_it_be(:iteration_cadence) { create(:iterations_cadence, group: group) }
......
......@@ -441,7 +441,7 @@ RSpec.describe EE::NotificationService, :mailer do
let(:guest) { create(:user) }
let(:admin) { create(:admin) }
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
project.add_developer(member)
......@@ -472,7 +472,7 @@ RSpec.describe EE::NotificationService, :mailer do
let(:mailer_method) { :changed_iteration_issue_email }
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) } }
it_behaves_like 'altered iteration notification on issue' do
......@@ -495,7 +495,7 @@ RSpec.describe EE::NotificationService, :mailer do
let(:guest) { create(:user) }
let(:admin) { create(:admin) }
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
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