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 ...@@ -51,7 +51,7 @@ module Milestoneable
# Overridden on EE module # Overridden on EE module
# #
def supports_milestone? def supports_milestone?
respond_to?(:milestone_id) && !incident? respond_to?(:milestone_id)
end end
end end
......
...@@ -58,7 +58,7 @@ ...@@ -58,7 +58,7 @@
.selectbox.hide-collapsed .selectbox.hide-collapsed
= f.hidden_field 'milestone_id', value: milestone[:id], id: nil = 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' }}) = 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 = 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] - 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 ...@@ -40,5 +40,9 @@ module EE
def supports_metric_images? def supports_metric_images?
incident? incident?
end end
def supports_iterations?
false
end
end end
end end
...@@ -157,6 +157,7 @@ module EE ...@@ -157,6 +157,7 @@ module EE
!incident? !incident?
end end
override :supports_iterations?
def supports_iterations? def supports_iterations?
!incident? !incident?
end end
......
...@@ -10,6 +10,7 @@ module EE ...@@ -10,6 +10,7 @@ module EE
end end
expose :supports_weight?, as: :supports_weight expose :supports_weight?, as: :supports_weight
expose :supports_iterations?, as: :supports_iterations
end end
end 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 } } .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 ...@@ -79,4 +79,29 @@ RSpec.describe EE::Issuable do
it { is_expected.to eq(weight_available) } it { is_expected.to eq(weight_available) }
end end
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 end
...@@ -45,7 +45,7 @@ RSpec.describe 'Incident details', :js do ...@@ -45,7 +45,7 @@ RSpec.describe 'Incident details', :js do
expect(page).to have_selector('.right-sidebar[data-issuable-type="issue"]') expect(page).to have_selector('.right-sidebar[data-issuable-type="issue"]')
expect(sidebar).to have_selector('.incident-severity') expect(sidebar).to have_selector('.incident-severity')
expect(sidebar).not_to have_selector('.milestone') expect(sidebar).to have_selector('.milestone')
end end
end end
end end
......
...@@ -223,8 +223,8 @@ RSpec.describe "User creates issue" do ...@@ -223,8 +223,8 @@ RSpec.describe "User creates issue" do
expect(page).not_to have_selector('.epic-dropdown-container') expect(page).not_to have_selector('.epic-dropdown-container')
end end
it 'hides the milestone select' do it 'shows the milestone select' do
expect(page).not_to have_selector('.qa-issuable-milestone-dropdown') expect(page).to have_selector('.qa-issuable-milestone-dropdown')
end end
it 'hides the weight input' do it 'hides the weight input' do
......
...@@ -104,8 +104,8 @@ RSpec.describe Milestoneable do ...@@ -104,8 +104,8 @@ RSpec.describe Milestoneable do
context "for incidents" do context "for incidents" do
let(:incident) { build(:incident) } let(:incident) { build(:incident) }
it 'returns false' do it 'returns true' do
expect(incident.supports_milestone?).to be_falsy expect(incident.supports_milestone?).to be_truthy
end end
end end
end end
......
...@@ -153,8 +153,8 @@ RSpec.describe Notes::QuickActionsService do ...@@ -153,8 +153,8 @@ RSpec.describe Notes::QuickActionsService do
expect(execute(note)).to be_empty expect(execute(note)).to be_empty
end end
it 'does not assign the milestone' do it 'assigns the milestone' do
expect { execute(note) }.not_to change { issue.reload.milestone } expect { execute(note) }.to change { issue.reload.milestone }.from(nil).to(milestone)
end end
end end
...@@ -195,8 +195,8 @@ RSpec.describe Notes::QuickActionsService do ...@@ -195,8 +195,8 @@ RSpec.describe Notes::QuickActionsService do
expect(execute(note)).to be_empty expect(execute(note)).to be_empty
end end
it 'does not remove the milestone' do it 'removes the milestone' do
expect { execute(note) }.not_to change { issue.reload.milestone } expect { execute(note) }.to change { issue.reload.milestone }.from(milestone).to(nil)
end end
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