diff --git a/app/models/dashboard_group_milestone.rb b/app/models/dashboard_group_milestone.rb
index 74aa04ab7d0fc48e9a3ccb001041541ca902ecd7..ec52f1ed370ef74e18650a0ff45f6477dfc7c278 100644
--- a/app/models/dashboard_group_milestone.rb
+++ b/app/models/dashboard_group_milestone.rb
@@ -15,8 +15,7 @@ class DashboardGroupMilestone < GlobalMilestone
milestones = Milestone.of_groups(groups.select(:id))
.reorder_by_due_date_asc
.order_by_name_asc
- .active
milestones = milestones.search_title(params[:search_title]) if params[:search_title].present?
- milestones.map { |m| new(m) }
+ Milestone.filter_by_state(milestones, params[:state]).map { |m| new(m) }
end
end
diff --git a/spec/controllers/dashboard/milestones_controller_spec.rb b/spec/controllers/dashboard/milestones_controller_spec.rb
index 4de537ae6f885ec1959980021a50d2671a6a5ee1..010d6ba477d9e9306e6c85c4533b3a6a534e92d5 100644
--- a/spec/controllers/dashboard/milestones_controller_spec.rb
+++ b/spec/controllers/dashboard/milestones_controller_spec.rb
@@ -59,6 +59,18 @@ describe Dashboard::MilestonesController do
expect(json_response.map { |i| i["group_name"] }.compact).to match_array(group.name)
end
+ it 'returns closed group and project milestones to which the user belongs' do
+ closed_group_milestone = create(:milestone, group: group, state: 'closed')
+ closed_project_milestone = create(:milestone, project: project, state: 'closed')
+
+ get :index, params: { state: 'closed' }, format: :json
+
+ expect(response).to have_gitlab_http_status(200)
+ expect(json_response.size).to eq(2)
+ expect(json_response.map { |i| i["name"] }).to match_array([closed_group_milestone.name, closed_project_milestone.name])
+ expect(json_response.map { |i| i["group_name"] }.compact).to match_array(group.name)
+ end
+
it 'searches legacy project milestones by title when search_title is given' do
project_milestone = create(:milestone, title: 'Project milestone title', project: project)
@@ -84,6 +96,16 @@ describe Dashboard::MilestonesController do
expect(response.body).to include("Closed\n0")
end
+ it 'shows counts of closed group and project milestones to which the user belongs to' do
+ closed_group_milestone = create(:milestone, group: group, state: 'closed')
+ closed_project_milestone = create(:milestone, project: project, state: 'closed')
+
+ get :index
+
+ expect(response.body).to include("Open\n2")
+ expect(response.body).to include("Closed\n2")
+ end
+
context 'external authorization' do
subject { get :index }