Commit 79a8e692 authored by David O'Regan's avatar David O'Regan

Update Incidents to allow milestones to be used

Add milestones to Incidents in both quick
actions and the sidebar
without adding iterations
parent d47aa728
......@@ -51,7 +51,7 @@ module Milestoneable
# Overridden on EE module
#
def supports_milestone?
respond_to?(:milestone_id) && !incident?
respond_to?(:milestone_id)
end
end
......
......@@ -58,7 +58,7 @@
.selectbox.hide-collapsed
= f.hidden_field 'milestone_id', value: milestone[:id], id: nil
= dropdown_tag('Milestone', options: { title: _('Assign milestone'), toggle_class: 'js-milestone-select js-extra-options', filter: true, dropdown_class: 'dropdown-menu-selectable', placeholder: _('Search milestones'), data: { show_no: true, field_name: "#{issuable_type}[milestone_id]", project_id: issuable_sidebar[:project_id], issuable_id: issuable_sidebar[:id], ability_name: issuable_type, issue_update: issuable_sidebar[:issuable_json_path], use_id: true, default_no: true, selected: milestone[:title], null_default: true, display: 'static' }})
- if @project.group.present?
- if @project.group.present? && issuable_sidebar[:supports_iterations]
= render_if_exists 'shared/issuable/iteration_select', can_edit: can_edit_issuable, group_path: @project.group.full_path, project_path: issuable_sidebar[:project_full_path], issue_iid: issuable_sidebar[:iid], issuable_type: issuable_type
- if issuable_sidebar[:supports_time_tracking]
......
---
title: 'Update Issue Incidents to allow the milestones feature to be used in the sidebar and quick actions'
merge_request: 51456
author:
type: changed
......@@ -40,5 +40,9 @@ module EE
def supports_metric_images?
incident?
end
def supports_iterations?
false
end
end
end
......@@ -157,6 +157,7 @@ module EE
!incident?
end
override :supports_iterations?
def supports_iterations?
!incident?
end
......
......@@ -10,6 +10,7 @@ module EE
end
expose :supports_weight?, as: :supports_weight
expose :supports_iterations?, as: :supports_iterations
end
end
end
- if Feature.enabled?(:group_iterations, @project.group, default_enabled: true) && @project.group.feature_available?(:iterations) && issuable_type == "issue"
- if Feature.enabled?(:group_iterations, @project.group, default_enabled: true) && @project.group.feature_available?(:iterations)
.js-iteration-select{ data: { can_edit: can_edit, group_path: group_path, project_path: project_path, issue_iid: issue_iid } }
......@@ -79,4 +79,29 @@ RSpec.describe EE::Issuable do
it { is_expected.to eq(weight_available) }
end
end
describe '#supports_iterations?' do
let(:group) { build_stubbed(:group) }
let(:project_with_group) { build_stubbed(:project, group: group) }
let(:project_without_group) { build_stubbed(:project) }
where(:issuable_type, :project, :supports_iterations) do
[
[:issue, :project_with_group, true],
[:issue, :project_without_group, true],
[:incident, :project_with_group, false],
[:incident, :project_without_group, false],
[:merge_request, :project_with_group, false],
[:merge_request, :project_without_group, false]
]
end
with_them do
let(:issuable) { build_stubbed(issuable_type, project: send(project)) }
subject { issuable.supports_iterations? }
it { is_expected.to eq(supports_iterations) }
end
end
end
......@@ -45,7 +45,7 @@ RSpec.describe 'Incident details', :js do
expect(page).to have_selector('.right-sidebar[data-issuable-type="issue"]')
expect(sidebar).to have_selector('.incident-severity')
expect(sidebar).not_to have_selector('.milestone')
expect(sidebar).to have_selector('.milestone')
end
end
end
......
......@@ -223,8 +223,8 @@ RSpec.describe "User creates issue" do
expect(page).not_to have_selector('.epic-dropdown-container')
end
it 'hides the milestone select' do
expect(page).not_to have_selector('.qa-issuable-milestone-dropdown')
it 'shows the milestone select' do
expect(page).to have_selector('.qa-issuable-milestone-dropdown')
end
it 'hides the weight input' do
......
......@@ -104,8 +104,8 @@ RSpec.describe Milestoneable do
context "for incidents" do
let(:incident) { build(:incident) }
it 'returns false' do
expect(incident.supports_milestone?).to be_falsy
it 'returns true' do
expect(incident.supports_milestone?).to be_truthy
end
end
end
......
......@@ -153,8 +153,8 @@ RSpec.describe Notes::QuickActionsService do
expect(execute(note)).to be_empty
end
it 'does not assign the milestone' do
expect { execute(note) }.not_to change { issue.reload.milestone }
it 'assigns the milestone' do
expect { execute(note) }.to change { issue.reload.milestone }.from(nil).to(milestone)
end
end
......@@ -195,8 +195,8 @@ RSpec.describe Notes::QuickActionsService do
expect(execute(note)).to be_empty
end
it 'does not remove the milestone' do
expect { execute(note) }.not_to change { issue.reload.milestone }
it 'removes the milestone' do
expect { execute(note) }.to change { issue.reload.milestone }.from(milestone).to(nil)
end
end
......
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