Fix bug with closed milestones in dashboard
This commit is contained in:
parent
b8d876f132
commit
6ff16f4bd0
2 changed files with 23 additions and 2 deletions
|
@ -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
|
||||
|
|
|
@ -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\n<span class=\"badge badge-pill\">0</span>")
|
||||
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\n<span class=\"badge badge-pill\">2</span>")
|
||||
expect(response.body).to include("Closed\n<span class=\"badge badge-pill\">2</span>")
|
||||
end
|
||||
|
||||
context 'external authorization' do
|
||||
subject { get :index }
|
||||
|
||||
|
|
Loading…
Reference in a new issue