Commit 063b035d authored by Sean McGivern's avatar Sean McGivern

Merge branch '34116-milestone-filtering-on-group-issues' into 'master'

Use correct milestones for filtering on Group Issues

Closes #34116

See merge request !12374
parents 2443ab69 b8430ddd
......@@ -11,6 +11,9 @@ class Groups::MilestonesController < Groups::ApplicationController
@milestone_states = GlobalMilestone.states_count(@projects)
@milestones = Kaminari.paginate_array(milestones).page(params[:page])
end
format.json do
render json: milestones.map { |m| m.for_display.slice(:title, :name) }
end
end
end
......
......@@ -74,6 +74,8 @@ module MilestonesHelper
project = @target_project || @project
if project
namespace_project_milestones_path(project.namespace, project, :json)
elsif @group
group_milestones_path(@group, :json)
else
dashboard_milestones_path(:json)
end
......
---
title: Change milestone endpoint for groups
merge_request: 12374
author: Takuya Noguchi
......@@ -23,6 +23,21 @@ describe Groups::MilestonesController do
project.team << [user, :master]
end
describe "#index" do
it 'shows group milestones page' do
get :index, group_id: group.to_param
expect(response).to have_http_status(200)
end
it 'shows group milestones JSON' do
get :index, group_id: group.to_param, format: :json
expect(response).to have_http_status(200)
expect(response.content_type).to eq 'application/json'
end
end
it_behaves_like 'milestone tabs'
describe "#create" do
......
require 'spec_helper'
describe MilestonesHelper do
describe '#milestones_filter_dropdown_path' do
let(:project) { create(:empty_project) }
let(:project2) { create(:empty_project) }
let(:group) { create(:group) }
context 'when @project present' do
it 'returns project milestones JSON URL' do
assign(:project, project)
expect(helper.milestones_filter_dropdown_path).to eq(namespace_project_milestones_path(project.namespace, project, :json))
end
end
context 'when @target_project present' do
it 'returns targeted project milestones JSON URL' do
assign(:target_project, project2)
expect(helper.milestones_filter_dropdown_path).to eq(namespace_project_milestones_path(project2.namespace, project2, :json))
end
end
context 'when @group present' do
it 'returns group milestones JSON URL' do
assign(:group, group)
expect(helper.milestones_filter_dropdown_path).to eq(group_milestones_path(group, :json))
end
end
context 'when neither of @project/@target_project/@group present' do
it 'returns dashboard milestones JSON URL' do
expect(helper.milestones_filter_dropdown_path).to eq(dashboard_milestones_path(:json))
end
end
end
describe "#milestone_date_range" do
def result_for(*args)
milestone_date_range(build(:milestone, *args))
......
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