2019-12-26 22:10:19 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-09-10 17:25:29 +05:30
|
|
|
require 'spec_helper'
|
|
|
|
|
2020-07-28 23:09:34 +05:30
|
|
|
RSpec.describe API::GroupMilestones do
|
2020-10-24 23:57:45 +05:30
|
|
|
let_it_be(:user) { create(:user) }
|
|
|
|
let_it_be(:group) { create(:group, :private) }
|
|
|
|
let_it_be(:project) { create(:project, namespace: group) }
|
|
|
|
let_it_be(:group_member) { create(:group_member, group: group, user: user) }
|
|
|
|
let_it_be(:closed_milestone) { create(:closed_milestone, group: group, title: 'version1', description: 'closed milestone') }
|
|
|
|
let_it_be(:milestone) { create(:milestone, group: group, title: 'version2', description: 'open milestone') }
|
|
|
|
let(:route) { "/groups/#{group.id}/milestones" }
|
|
|
|
|
|
|
|
it_behaves_like 'group and project milestones', "/groups/:id/milestones"
|
|
|
|
|
|
|
|
describe 'GET /groups/:id/milestones' do
|
|
|
|
context 'when include_parent_milestones is true' do
|
|
|
|
let_it_be(:ancestor_group) { create(:group, :private) }
|
|
|
|
let_it_be(:ancestor_group_milestone) { create(:milestone, group: ancestor_group) }
|
|
|
|
let_it_be(:params) { { include_parent_milestones: true } }
|
|
|
|
|
|
|
|
before_all do
|
|
|
|
group.update(parent: ancestor_group)
|
|
|
|
end
|
|
|
|
|
|
|
|
shared_examples 'listing all milestones' do
|
|
|
|
it 'returns correct list of milestones' do
|
|
|
|
get api(route, user), params: params
|
|
|
|
|
|
|
|
expect(response).to have_gitlab_http_status(:ok)
|
|
|
|
expect(json_response.size).to eq(milestones.size)
|
|
|
|
expect(json_response.map { |entry| entry["id"] }).to eq(milestones.map(&:id))
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when user has access to ancestor groups' do
|
|
|
|
let(:milestones) { [ancestor_group_milestone, milestone, closed_milestone] }
|
|
|
|
|
|
|
|
before do
|
|
|
|
ancestor_group.add_guest(user)
|
|
|
|
group.add_guest(user)
|
|
|
|
end
|
|
|
|
|
|
|
|
it_behaves_like 'listing all milestones'
|
|
|
|
|
|
|
|
context 'when iids param is present' do
|
|
|
|
let_it_be(:params) { { include_parent_milestones: true, iids: [milestone.iid] } }
|
|
|
|
|
|
|
|
it_behaves_like 'listing all milestones'
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when user has no access to ancestor groups' do
|
|
|
|
let(:user) { create(:user) }
|
|
|
|
|
|
|
|
before do
|
|
|
|
group.add_guest(user)
|
|
|
|
end
|
|
|
|
|
|
|
|
it_behaves_like 'listing all milestones' do
|
|
|
|
let(:milestones) { [milestone, closed_milestone] }
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2017-09-10 17:25:29 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
def setup_for_group
|
|
|
|
context_group.update(visibility_level: Gitlab::VisibilityLevel::PUBLIC)
|
|
|
|
context_group.add_developer(user)
|
|
|
|
public_project.update(namespace: context_group)
|
|
|
|
context_group.reload
|
|
|
|
end
|
|
|
|
end
|