Commit 21bab0e2 authored by GitLab Bot's avatar GitLab Bot

Automatic merge of gitlab-org/gitlab-ce master

parents e9e519ac 0b859d2f
...@@ -15,8 +15,7 @@ class DashboardGroupMilestone < GlobalMilestone ...@@ -15,8 +15,7 @@ class DashboardGroupMilestone < GlobalMilestone
milestones = Milestone.of_groups(groups.select(:id)) milestones = Milestone.of_groups(groups.select(:id))
.reorder_by_due_date_asc .reorder_by_due_date_asc
.order_by_name_asc .order_by_name_asc
.active
milestones = milestones.search_title(params[:search_title]) if params[:search_title].present? 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
end end
---
title: Fix bug in dashboard display of closed milestones
merge_request: 30820
author:
type: fixed
...@@ -47,6 +47,8 @@ describe Dashboard::MilestonesController do ...@@ -47,6 +47,8 @@ describe Dashboard::MilestonesController do
describe "#index" do describe "#index" do
let(:public_group) { create(:group, :public) } let(:public_group) { create(:group, :public) }
let!(:public_milestone) { create(:milestone, group: public_group) } let!(:public_milestone) { create(:milestone, group: public_group) }
let!(:closed_group_milestone) { create(:milestone, group: group, state: 'closed') }
let!(:closed_project_milestone) { create(:milestone, project: project, state: 'closed') }
render_views render_views
...@@ -59,6 +61,15 @@ describe Dashboard::MilestonesController do ...@@ -59,6 +61,15 @@ describe Dashboard::MilestonesController do
expect(json_response.map { |i| i["group_name"] }.compact).to match_array(group.name) expect(json_response.map { |i| i["group_name"] }.compact).to match_array(group.name)
end end
it 'returns closed group and project milestones to which the user belongs' do
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 it 'searches legacy project milestones by title when search_title is given' do
project_milestone = create(:milestone, title: 'Project milestone title', project: project) project_milestone = create(:milestone, title: 'Project milestone title', project: project)
...@@ -77,11 +88,11 @@ describe Dashboard::MilestonesController do ...@@ -77,11 +88,11 @@ describe Dashboard::MilestonesController do
expect(response.body).not_to include(project_milestone.title) expect(response.body).not_to include(project_milestone.title)
end end
it 'shows counts of group and project milestones to which the user belongs to' do it 'shows counts of open and closed group and project milestones to which the user belongs to' do
get :index get :index
expect(response.body).to include("Open\n<span class=\"badge badge-pill\">2</span>") expect(response.body).to include("Open\n<span class=\"badge badge-pill\">2</span>")
expect(response.body).to include("Closed\n<span class=\"badge badge-pill\">0</span>") expect(response.body).to include("Closed\n<span class=\"badge badge-pill\">2</span>")
end end
context 'external authorization' do context 'external authorization' do
......
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