Commit 76b80d6e authored by Sean McGivern's avatar Sean McGivern

Show group milestones in autocomplete

parent ca923d48
...@@ -5,7 +5,15 @@ module Projects ...@@ -5,7 +5,15 @@ module Projects
end end
def milestones def milestones
@project.milestones.active.reorder(due_date: :asc, title: :asc).select([:iid, :title]) finder_params = {
project_ids: [@project.id],
state: :active,
order: { due_date: :asc, title: :asc }
}
finder_params[:group_ids] = [@project.group.id] if @project.group
MilestonesFinder.new(finder_params).execute.select([:iid, :title])
end end
def merge_requests def merge_requests
......
---
title: Support Markdown references, autocomplete, and quick actions for group milestones
merge_request:
author:
...@@ -56,4 +56,5 @@ total merge requests and issues. ...@@ -56,4 +56,5 @@ total merge requests and issues.
## Quick actions ## Quick actions
[Quick actions](../quick_actions.md) are available for assigning and removing project milestones only. [In the future](https://gitlab.com/gitlab-org/gitlab-ce/issues/34778), this will also apply to group milestones. [Quick actions](../quick_actions.md) are available for assigning and removing
project and group milestones.
...@@ -88,4 +88,31 @@ describe Projects::AutocompleteService do ...@@ -88,4 +88,31 @@ describe Projects::AutocompleteService do
end end
end end
end end
describe '#milestones' do
let(:user) { create(:user) }
let(:group) { create(:group) }
let(:project) { create(:project, group: group) }
let!(:group_milestone) { create(:milestone, group: group) }
let!(:project_milestone) { create(:milestone, project: project) }
let(:milestone_titles) { described_class.new(project, user).milestones.map(&:title) }
it 'includes project and group milestones' do
expect(milestone_titles).to eq([group_milestone.title, project_milestone.title])
end
it 'does not include closed milestones' do
group_milestone.close
expect(milestone_titles).to eq([project_milestone.title])
end
it 'does not include milestones from other projects in the group' do
other_project = create(:project, group: group)
project_milestone.update!(project: other_project)
expect(milestone_titles).to eq([group_milestone.title])
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