2017-07-12 15:58:48 -04:00
|
|
|
shared_examples_for 'group and project milestones' do |route_definition|
|
|
|
|
let(:resource_route) { "#{route}/#{milestone.id}" }
|
2017-06-09 14:53:32 -04:00
|
|
|
let(:label_1) { create(:label, title: 'label_1', project: project, priority: 1) }
|
|
|
|
let(:label_2) { create(:label, title: 'label_2', project: project, priority: 2) }
|
|
|
|
let(:label_3) { create(:label, title: 'label_3', project: project) }
|
2017-07-12 15:58:48 -04:00
|
|
|
let(:merge_request) { create(:merge_request, source_project: project) }
|
|
|
|
let(:another_merge_request) { create(:merge_request, :simple, source_project: project) }
|
2012-08-16 14:51:31 -04:00
|
|
|
|
2017-07-12 15:58:48 -04:00
|
|
|
describe "GET #{route_definition}" do
|
|
|
|
it 'returns milestones list' do
|
|
|
|
get api(route, user)
|
2016-09-12 15:14:26 -04:00
|
|
|
|
2017-10-19 14:28:19 -04:00
|
|
|
expect(response).to have_gitlab_http_status(200)
|
2017-01-24 15:49:10 -05:00
|
|
|
expect(response).to include_pagination_headers
|
2015-02-12 13:17:35 -05:00
|
|
|
expect(json_response).to be_an Array
|
|
|
|
expect(json_response.first['title']).to eq(milestone.title)
|
2012-08-16 14:51:31 -04:00
|
|
|
end
|
2013-02-20 16:51:59 -05:00
|
|
|
|
2016-08-01 11:00:44 -04:00
|
|
|
it 'returns a 401 error if user not authenticated' do
|
2017-07-12 15:58:48 -04:00
|
|
|
get api(route)
|
2016-09-12 15:14:26 -04:00
|
|
|
|
2017-10-19 14:28:19 -04:00
|
|
|
expect(response).to have_gitlab_http_status(401)
|
2013-02-20 16:51:59 -05:00
|
|
|
end
|
2016-04-06 07:03:07 -04:00
|
|
|
|
2016-04-06 14:53:17 -04:00
|
|
|
it 'returns an array of active milestones' do
|
2017-07-12 15:58:48 -04:00
|
|
|
get api("#{route}/?state=active", user)
|
2016-04-06 14:53:17 -04:00
|
|
|
|
2017-10-19 14:28:19 -04:00
|
|
|
expect(response).to have_gitlab_http_status(200)
|
2017-01-24 15:49:10 -05:00
|
|
|
expect(response).to include_pagination_headers
|
2016-04-06 07:03:07 -04:00
|
|
|
expect(json_response).to be_an Array
|
|
|
|
expect(json_response.length).to eq(1)
|
|
|
|
expect(json_response.first['id']).to eq(milestone.id)
|
|
|
|
end
|
|
|
|
|
2016-04-06 14:53:17 -04:00
|
|
|
it 'returns an array of closed milestones' do
|
2017-07-12 15:58:48 -04:00
|
|
|
get api("#{route}/?state=closed", user)
|
2016-04-06 14:53:17 -04:00
|
|
|
|
2017-10-19 14:28:19 -04:00
|
|
|
expect(response).to have_gitlab_http_status(200)
|
2017-01-24 15:49:10 -05:00
|
|
|
expect(response).to include_pagination_headers
|
2016-04-06 07:03:07 -04:00
|
|
|
expect(json_response).to be_an Array
|
|
|
|
expect(json_response.length).to eq(1)
|
|
|
|
expect(json_response.first['id']).to eq(closed_milestone.id)
|
|
|
|
end
|
2013-02-06 09:05:56 -05:00
|
|
|
|
2017-02-09 09:28:19 -05:00
|
|
|
it 'returns an array of milestones specified by iids' do
|
2017-07-12 15:58:48 -04:00
|
|
|
other_milestone = create(:milestone, project: try(:project), group: try(:group))
|
2017-02-09 09:28:19 -05:00
|
|
|
|
2017-07-12 15:58:48 -04:00
|
|
|
get api(route, user), iids: [closed_milestone.iid, other_milestone.iid]
|
2017-02-09 09:28:19 -05:00
|
|
|
|
2017-10-19 14:28:19 -04:00
|
|
|
expect(response).to have_gitlab_http_status(200)
|
2017-02-09 09:28:19 -05:00
|
|
|
expect(json_response).to be_an Array
|
|
|
|
expect(json_response.length).to eq(2)
|
2017-08-09 05:52:22 -04:00
|
|
|
expect(json_response.map { |m| m['id'] }).to match_array([closed_milestone.id, other_milestone.id])
|
2017-02-09 09:28:19 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'does not return any milestone if none found' do
|
2017-07-12 15:58:48 -04:00
|
|
|
get api(route, user), iids: [Milestone.maximum(:iid).succ]
|
2017-02-09 09:28:19 -05:00
|
|
|
|
2017-10-19 14:28:19 -04:00
|
|
|
expect(response).to have_gitlab_http_status(200)
|
2017-02-09 09:28:19 -05:00
|
|
|
expect(json_response).to be_an Array
|
|
|
|
expect(json_response.length).to eq(0)
|
|
|
|
end
|
|
|
|
|
2017-07-12 15:58:48 -04:00
|
|
|
it 'returns a milestone by iids array' do
|
|
|
|
get api("#{route}?iids=#{closed_milestone.iid}", user)
|
2016-04-07 04:59:54 -04:00
|
|
|
|
2015-06-13 18:24:51 -04:00
|
|
|
expect(response.status).to eq 200
|
2017-01-24 15:49:10 -05:00
|
|
|
expect(response).to include_pagination_headers
|
|
|
|
expect(json_response.size).to eq(1)
|
2016-04-07 04:59:54 -04:00
|
|
|
expect(json_response.size).to eq(1)
|
|
|
|
expect(json_response.first['title']).to eq closed_milestone.title
|
|
|
|
expect(json_response.first['id']).to eq closed_milestone.id
|
2015-01-17 17:45:39 -05:00
|
|
|
end
|
|
|
|
|
2017-07-12 15:58:48 -04:00
|
|
|
it 'returns a milestone by searching for title' do
|
|
|
|
get api(route, user), search: 'version2'
|
2017-01-24 15:49:10 -05:00
|
|
|
|
2017-10-19 14:28:19 -04:00
|
|
|
expect(response).to have_gitlab_http_status(200)
|
2017-01-24 15:49:10 -05:00
|
|
|
expect(response).to include_pagination_headers
|
2017-02-28 07:23:40 -05:00
|
|
|
expect(json_response.size).to eq(1)
|
|
|
|
expect(json_response.first['title']).to eq milestone.title
|
|
|
|
expect(json_response.first['id']).to eq milestone.id
|
|
|
|
end
|
|
|
|
|
2017-07-12 15:58:48 -04:00
|
|
|
it 'returns a milestones by searching for description' do
|
|
|
|
get api(route, user), search: 'open'
|
2017-02-28 07:23:40 -05:00
|
|
|
|
2017-10-19 14:28:19 -04:00
|
|
|
expect(response).to have_gitlab_http_status(200)
|
2017-02-28 07:23:40 -05:00
|
|
|
expect(response).to include_pagination_headers
|
|
|
|
expect(json_response.size).to eq(1)
|
2017-01-24 15:49:10 -05:00
|
|
|
expect(json_response.first['title']).to eq milestone.title
|
|
|
|
expect(json_response.first['id']).to eq milestone.id
|
|
|
|
end
|
2017-01-16 23:45:07 -05:00
|
|
|
end
|
|
|
|
|
2017-07-12 15:58:48 -04:00
|
|
|
describe "GET #{route_definition}/:milestone_id" do
|
|
|
|
it 'returns a milestone by id' do
|
|
|
|
get api(resource_route, user)
|
|
|
|
|
2017-10-19 14:28:19 -04:00
|
|
|
expect(response).to have_gitlab_http_status(200)
|
2017-07-12 15:58:48 -04:00
|
|
|
expect(json_response['title']).to eq(milestone.title)
|
|
|
|
expect(json_response['iid']).to eq(milestone.iid)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'returns a milestone by id' do
|
|
|
|
get api(resource_route, user)
|
2017-01-16 23:45:07 -05:00
|
|
|
|
2017-10-19 14:28:19 -04:00
|
|
|
expect(response).to have_gitlab_http_status(200)
|
2017-01-16 23:45:07 -05:00
|
|
|
expect(json_response['title']).to eq(milestone.title)
|
|
|
|
expect(json_response['iid']).to eq(milestone.iid)
|
|
|
|
end
|
2016-11-22 02:23:43 -05:00
|
|
|
|
2016-08-01 11:00:44 -04:00
|
|
|
it 'returns 401 error if user not authenticated' do
|
2017-07-12 15:58:48 -04:00
|
|
|
get api(resource_route)
|
2016-09-12 15:14:26 -04:00
|
|
|
|
2017-10-19 14:28:19 -04:00
|
|
|
expect(response).to have_gitlab_http_status(401)
|
2013-02-20 16:51:59 -05:00
|
|
|
end
|
|
|
|
|
2016-08-01 11:00:44 -04:00
|
|
|
it 'returns a 404 error if milestone id not found' do
|
2017-07-12 15:58:48 -04:00
|
|
|
get api("#{route}/1234", user)
|
2016-09-12 15:14:26 -04:00
|
|
|
|
2017-10-19 14:28:19 -04:00
|
|
|
expect(response).to have_gitlab_http_status(404)
|
2013-02-06 09:05:56 -05:00
|
|
|
end
|
2012-08-16 14:51:31 -04:00
|
|
|
end
|
|
|
|
|
2017-07-12 15:58:48 -04:00
|
|
|
describe "POST #{route_definition}" do
|
|
|
|
it 'creates a new milestone' do
|
|
|
|
post api(route, user), title: 'new milestone'
|
2016-09-12 15:14:26 -04:00
|
|
|
|
2017-10-19 14:28:19 -04:00
|
|
|
expect(response).to have_gitlab_http_status(201)
|
2015-02-12 13:17:35 -05:00
|
|
|
expect(json_response['title']).to eq('new milestone')
|
|
|
|
expect(json_response['description']).to be_nil
|
2012-08-16 14:51:31 -04:00
|
|
|
end
|
2013-02-06 09:05:56 -05:00
|
|
|
|
2017-07-12 15:58:48 -04:00
|
|
|
it 'creates a new milestone with description and dates' do
|
|
|
|
post api(route, user),
|
2016-11-15 12:48:30 -05:00
|
|
|
title: 'new milestone', description: 'release', due_date: '2013-03-02', start_date: '2013-02-02'
|
2016-09-12 15:14:26 -04:00
|
|
|
|
2017-10-19 14:28:19 -04:00
|
|
|
expect(response).to have_gitlab_http_status(201)
|
2015-02-12 13:17:35 -05:00
|
|
|
expect(json_response['description']).to eq('release')
|
|
|
|
expect(json_response['due_date']).to eq('2013-03-02')
|
2016-11-15 12:48:30 -05:00
|
|
|
expect(json_response['start_date']).to eq('2013-02-02')
|
2013-02-06 09:05:56 -05:00
|
|
|
end
|
|
|
|
|
2016-08-01 11:00:44 -04:00
|
|
|
it 'returns a 400 error if title is missing' do
|
2017-07-12 15:58:48 -04:00
|
|
|
post api(route, user)
|
2016-09-12 15:14:26 -04:00
|
|
|
|
2017-10-19 14:28:19 -04:00
|
|
|
expect(response).to have_gitlab_http_status(400)
|
2016-09-12 15:14:26 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'returns a 400 error if params are invalid (duplicate title)' do
|
2017-07-12 15:58:48 -04:00
|
|
|
post api(route, user),
|
2016-09-12 15:14:26 -04:00
|
|
|
title: milestone.title, description: 'release', due_date: '2013-03-02'
|
|
|
|
|
2017-10-19 14:28:19 -04:00
|
|
|
expect(response).to have_gitlab_http_status(400)
|
2013-02-06 09:05:56 -05:00
|
|
|
end
|
2016-09-26 19:47:34 -04:00
|
|
|
|
2017-07-12 15:58:48 -04:00
|
|
|
it 'creates a new milestone with reserved html characters' do
|
|
|
|
post api(route, user), title: 'foo & bar 1.1 -> 2.2'
|
2016-09-26 19:47:34 -04:00
|
|
|
|
2017-10-19 14:28:19 -04:00
|
|
|
expect(response).to have_gitlab_http_status(201)
|
2016-09-26 19:47:34 -04:00
|
|
|
expect(json_response['title']).to eq('foo & bar 1.1 -> 2.2')
|
|
|
|
expect(json_response['description']).to be_nil
|
|
|
|
end
|
2012-08-16 14:51:31 -04:00
|
|
|
end
|
|
|
|
|
2017-07-12 15:58:48 -04:00
|
|
|
describe "PUT #{route_definition}/:milestone_id" do
|
|
|
|
it 'updates a milestone' do
|
|
|
|
put api(resource_route, user),
|
2012-08-16 14:51:31 -04:00
|
|
|
title: 'updated title'
|
2016-09-12 15:14:26 -04:00
|
|
|
|
2017-10-19 14:28:19 -04:00
|
|
|
expect(response).to have_gitlab_http_status(200)
|
2015-02-12 13:17:35 -05:00
|
|
|
expect(json_response['title']).to eq('updated title')
|
2012-08-16 14:51:31 -04:00
|
|
|
end
|
2013-02-06 09:05:56 -05:00
|
|
|
|
2016-11-09 09:14:02 -05:00
|
|
|
it 'removes a due date if nil is passed' do
|
|
|
|
milestone.update!(due_date: "2016-08-05")
|
|
|
|
|
2017-07-12 15:58:48 -04:00
|
|
|
put api(resource_route, user), due_date: nil
|
2016-11-09 09:14:02 -05:00
|
|
|
|
2017-10-19 14:28:19 -04:00
|
|
|
expect(response).to have_gitlab_http_status(200)
|
2016-11-09 09:14:02 -05:00
|
|
|
expect(json_response['due_date']).to be_nil
|
|
|
|
end
|
|
|
|
|
2016-08-01 11:00:44 -04:00
|
|
|
it 'returns a 404 error if milestone id not found' do
|
2017-07-12 15:58:48 -04:00
|
|
|
put api("#{route}/1234", user),
|
2013-02-06 09:05:56 -05:00
|
|
|
title: 'updated title'
|
2016-09-12 15:14:26 -04:00
|
|
|
|
2017-10-19 14:28:19 -04:00
|
|
|
expect(response).to have_gitlab_http_status(404)
|
2013-02-06 09:05:56 -05:00
|
|
|
end
|
2013-02-18 04:10:09 -05:00
|
|
|
|
2017-07-12 15:58:48 -04:00
|
|
|
it 'closes milestone' do
|
|
|
|
put api(resource_route, user),
|
2013-02-18 04:10:09 -05:00
|
|
|
state_event: 'close'
|
2017-10-19 14:28:19 -04:00
|
|
|
expect(response).to have_gitlab_http_status(200)
|
2013-02-18 04:10:09 -05:00
|
|
|
|
2015-02-12 13:17:35 -05:00
|
|
|
expect(json_response['state']).to eq('closed')
|
2013-02-18 04:10:09 -05:00
|
|
|
end
|
|
|
|
end
|
2013-10-04 15:11:50 -04:00
|
|
|
|
2017-07-12 15:58:48 -04:00
|
|
|
describe "GET #{route_definition}/:milestone_id/issues" do
|
|
|
|
let(:issues_route) { "#{route}/#{milestone.id}/issues" }
|
2014-06-02 19:10:38 -04:00
|
|
|
|
2015-01-21 17:59:30 -05:00
|
|
|
before do
|
2016-04-24 23:07:59 -04:00
|
|
|
milestone.issues << create(:issue, project: project)
|
2015-01-21 17:59:30 -05:00
|
|
|
end
|
2017-07-12 15:58:48 -04:00
|
|
|
it 'returns issues for a particular milestone' do
|
|
|
|
get api(issues_route, user)
|
2016-09-12 15:14:26 -04:00
|
|
|
|
2017-10-19 14:28:19 -04:00
|
|
|
expect(response).to have_gitlab_http_status(200)
|
2017-01-24 15:49:10 -05:00
|
|
|
expect(response).to include_pagination_headers
|
2015-02-12 13:17:35 -05:00
|
|
|
expect(json_response).to be_an Array
|
|
|
|
expect(json_response.first['milestone']['title']).to eq(milestone.title)
|
2014-06-02 19:10:38 -04:00
|
|
|
end
|
|
|
|
|
2017-07-12 15:58:48 -04:00
|
|
|
it 'returns issues sorted by label priority' do
|
2017-06-09 14:53:32 -04:00
|
|
|
issue_1 = create(:labeled_issue, project: project, milestone: milestone, labels: [label_3])
|
|
|
|
issue_2 = create(:labeled_issue, project: project, milestone: milestone, labels: [label_1])
|
|
|
|
issue_3 = create(:labeled_issue, project: project, milestone: milestone, labels: [label_2])
|
|
|
|
|
2017-07-12 15:58:48 -04:00
|
|
|
get api(issues_route, user)
|
2017-06-09 14:53:32 -04:00
|
|
|
|
|
|
|
expect(json_response.first['id']).to eq(issue_2.id)
|
|
|
|
expect(json_response.second['id']).to eq(issue_3.id)
|
|
|
|
expect(json_response.third['id']).to eq(issue_1.id)
|
|
|
|
end
|
|
|
|
|
2017-03-06 06:48:10 -05:00
|
|
|
it 'matches V4 response schema for a list of issues' do
|
2017-07-12 15:58:48 -04:00
|
|
|
get api(issues_route, user)
|
2017-03-06 06:48:10 -05:00
|
|
|
|
2017-10-19 14:28:19 -04:00
|
|
|
expect(response).to have_gitlab_http_status(200)
|
2017-03-06 06:48:10 -05:00
|
|
|
expect(response).to match_response_schema('public_api/v4/issues')
|
|
|
|
end
|
|
|
|
|
2016-08-01 11:00:44 -04:00
|
|
|
it 'returns a 401 error if user not authenticated' do
|
2017-07-12 15:58:48 -04:00
|
|
|
get api(issues_route)
|
2016-09-12 15:14:26 -04:00
|
|
|
|
2017-10-19 14:28:19 -04:00
|
|
|
expect(response).to have_gitlab_http_status(401)
|
2014-06-02 19:10:38 -04:00
|
|
|
end
|
2016-04-24 23:07:59 -04:00
|
|
|
|
2016-04-25 05:49:52 -04:00
|
|
|
describe 'confidential issues' do
|
2017-08-02 15:55:11 -04:00
|
|
|
let!(:public_project) { create(:project, :public) }
|
2017-07-12 15:58:48 -04:00
|
|
|
let!(:context_group) { try(:group) }
|
|
|
|
let!(:milestone) do
|
|
|
|
context_group ? create(:milestone, group: context_group) : create(:milestone, project: public_project)
|
|
|
|
end
|
|
|
|
let!(:issue) { create(:issue, project: public_project) }
|
|
|
|
let!(:confidential_issue) { create(:issue, confidential: true, project: public_project) }
|
|
|
|
let!(:issues_route) do
|
|
|
|
if context_group
|
|
|
|
"#{route}/#{milestone.id}/issues"
|
|
|
|
else
|
|
|
|
"/projects/#{public_project.id}/milestones/#{milestone.id}/issues"
|
|
|
|
end
|
|
|
|
end
|
2016-06-06 15:13:31 -04:00
|
|
|
|
2016-04-25 05:49:52 -04:00
|
|
|
before do
|
2017-07-12 15:58:48 -04:00
|
|
|
# Add public project to the group in context
|
|
|
|
setup_for_group if context_group
|
|
|
|
|
2017-12-22 03:18:28 -05:00
|
|
|
public_project.add_developer(user)
|
2016-04-25 05:49:52 -04:00
|
|
|
milestone.issues << issue << confidential_issue
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'returns confidential issues to team members' do
|
2017-07-12 15:58:48 -04:00
|
|
|
get api(issues_route, user)
|
2016-04-25 05:49:52 -04:00
|
|
|
|
2017-10-19 14:28:19 -04:00
|
|
|
expect(response).to have_gitlab_http_status(200)
|
2017-01-24 15:49:10 -05:00
|
|
|
expect(response).to include_pagination_headers
|
2016-04-25 05:49:52 -04:00
|
|
|
expect(json_response).to be_an Array
|
2017-07-12 15:58:48 -04:00
|
|
|
# 2 for projects, 3 for group(which has another project with an issue)
|
|
|
|
expect(json_response.size).to be_between(2, 3)
|
2016-04-25 05:49:52 -04:00
|
|
|
expect(json_response.map { |issue| issue['id'] }).to include(issue.id, confidential_issue.id)
|
|
|
|
end
|
|
|
|
|
2016-06-06 15:13:31 -04:00
|
|
|
it 'does not return confidential issues to team members with guest role' do
|
|
|
|
member = create(:user)
|
2017-12-22 03:18:28 -05:00
|
|
|
public_project.add_guest(member)
|
2016-06-06 15:13:31 -04:00
|
|
|
|
2017-07-12 15:58:48 -04:00
|
|
|
get api(issues_route, member)
|
2016-06-06 15:13:31 -04:00
|
|
|
|
2017-10-19 14:28:19 -04:00
|
|
|
expect(response).to have_gitlab_http_status(200)
|
2017-01-24 15:49:10 -05:00
|
|
|
expect(response).to include_pagination_headers
|
2016-06-06 15:13:31 -04:00
|
|
|
expect(json_response).to be_an Array
|
|
|
|
expect(json_response.size).to eq(1)
|
|
|
|
expect(json_response.map { |issue| issue['id'] }).to include(issue.id)
|
|
|
|
end
|
|
|
|
|
2016-04-25 05:49:52 -04:00
|
|
|
it 'does not return confidential issues to regular users' do
|
2017-07-12 15:58:48 -04:00
|
|
|
get api(issues_route, create(:user))
|
2016-04-25 05:49:52 -04:00
|
|
|
|
2017-10-19 14:28:19 -04:00
|
|
|
expect(response).to have_gitlab_http_status(200)
|
2017-01-24 15:49:10 -05:00
|
|
|
expect(response).to include_pagination_headers
|
2016-04-25 05:49:52 -04:00
|
|
|
expect(json_response).to be_an Array
|
|
|
|
expect(json_response.size).to eq(1)
|
|
|
|
expect(json_response.map { |issue| issue['id'] }).to include(issue.id)
|
|
|
|
end
|
2017-03-09 13:43:07 -05:00
|
|
|
|
2017-06-09 14:53:32 -04:00
|
|
|
it 'returns issues ordered by label priority' do
|
|
|
|
issue.labels << label_2
|
|
|
|
confidential_issue.labels << label_1
|
|
|
|
|
2017-07-12 15:58:48 -04:00
|
|
|
get api(issues_route, user)
|
2017-03-09 13:43:07 -05:00
|
|
|
|
2017-10-19 14:28:19 -04:00
|
|
|
expect(response).to have_gitlab_http_status(200)
|
2017-03-09 13:43:07 -05:00
|
|
|
expect(response).to include_pagination_headers
|
|
|
|
expect(json_response).to be_an Array
|
2017-07-12 15:58:48 -04:00
|
|
|
# 2 for projects, 3 for group(which has another project with an issue)
|
|
|
|
expect(json_response.size).to be_between(2, 3)
|
2017-03-09 13:43:07 -05:00
|
|
|
expect(json_response.first['id']).to eq(confidential_issue.id)
|
|
|
|
expect(json_response.second['id']).to eq(issue.id)
|
|
|
|
end
|
2016-04-24 23:07:59 -04:00
|
|
|
end
|
|
|
|
end
|
2017-02-16 04:08:18 -05:00
|
|
|
|
2017-07-12 15:58:48 -04:00
|
|
|
describe "GET #{route_definition}/:milestone_id/merge_requests" do
|
|
|
|
let(:merge_requests_route) { "#{route}/#{milestone.id}/merge_requests" }
|
2017-03-09 13:43:07 -05:00
|
|
|
|
2017-02-16 04:08:18 -05:00
|
|
|
before do
|
|
|
|
milestone.merge_requests << merge_request
|
|
|
|
end
|
|
|
|
|
2017-07-12 15:58:48 -04:00
|
|
|
it 'returns merge_requests for a particular milestone' do
|
2017-03-31 05:38:40 -04:00
|
|
|
# eager-load another_merge_request
|
|
|
|
another_merge_request
|
2017-07-12 15:58:48 -04:00
|
|
|
get api(merge_requests_route, user)
|
2017-02-16 04:08:18 -05:00
|
|
|
|
2017-10-19 14:28:19 -04:00
|
|
|
expect(response).to have_gitlab_http_status(200)
|
2017-02-16 04:08:18 -05:00
|
|
|
expect(json_response).to be_an Array
|
|
|
|
expect(json_response.size).to eq(1)
|
|
|
|
expect(json_response.first['title']).to eq(merge_request.title)
|
|
|
|
expect(json_response.first['milestone']['title']).to eq(milestone.title)
|
|
|
|
end
|
|
|
|
|
2017-07-12 15:58:48 -04:00
|
|
|
it 'returns merge_requests sorted by label priority' do
|
2017-06-09 14:53:32 -04:00
|
|
|
merge_request_1 = create(:labeled_merge_request, source_branch: 'branch_1', source_project: project, milestone: milestone, labels: [label_2])
|
|
|
|
merge_request_2 = create(:labeled_merge_request, source_branch: 'branch_2', source_project: project, milestone: milestone, labels: [label_1])
|
|
|
|
merge_request_3 = create(:labeled_merge_request, source_branch: 'branch_3', source_project: project, milestone: milestone, labels: [label_3])
|
|
|
|
|
2017-07-12 15:58:48 -04:00
|
|
|
get api(merge_requests_route, user)
|
2017-06-09 14:53:32 -04:00
|
|
|
|
|
|
|
expect(json_response.first['id']).to eq(merge_request_2.id)
|
|
|
|
expect(json_response.second['id']).to eq(merge_request_1.id)
|
|
|
|
expect(json_response.third['id']).to eq(merge_request_3.id)
|
|
|
|
end
|
|
|
|
|
2017-02-16 04:08:18 -05:00
|
|
|
it 'returns a 404 error if milestone id not found' do
|
2017-07-12 15:58:48 -04:00
|
|
|
not_found_route = "#{route}/1234/merge_requests"
|
|
|
|
|
|
|
|
get api(not_found_route, user)
|
2017-02-16 04:08:18 -05:00
|
|
|
|
2017-10-19 14:28:19 -04:00
|
|
|
expect(response).to have_gitlab_http_status(404)
|
2017-02-16 04:08:18 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'returns a 404 if the user has no access to the milestone' do
|
|
|
|
new_user = create :user
|
2017-07-12 15:58:48 -04:00
|
|
|
get api(merge_requests_route, new_user)
|
2017-02-16 04:08:18 -05:00
|
|
|
|
2017-10-19 14:28:19 -04:00
|
|
|
expect(response).to have_gitlab_http_status(404)
|
2017-02-16 04:08:18 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'returns a 401 error if user not authenticated' do
|
2017-07-12 15:58:48 -04:00
|
|
|
get api(merge_requests_route)
|
2017-02-16 04:08:18 -05:00
|
|
|
|
2017-10-19 14:28:19 -04:00
|
|
|
expect(response).to have_gitlab_http_status(401)
|
2017-02-16 04:08:18 -05:00
|
|
|
end
|
2017-03-09 13:43:07 -05:00
|
|
|
|
|
|
|
it 'returns merge_requests ordered by position asc' do
|
|
|
|
milestone.merge_requests << another_merge_request
|
2017-06-09 14:53:32 -04:00
|
|
|
another_merge_request.labels << label_1
|
|
|
|
merge_request.labels << label_2
|
2017-03-09 13:43:07 -05:00
|
|
|
|
2017-07-12 15:58:48 -04:00
|
|
|
get api(merge_requests_route, user)
|
2017-03-09 13:43:07 -05:00
|
|
|
|
2017-10-19 14:28:19 -04:00
|
|
|
expect(response).to have_gitlab_http_status(200)
|
2017-03-09 13:43:07 -05:00
|
|
|
expect(response).to include_pagination_headers
|
|
|
|
expect(json_response).to be_an Array
|
|
|
|
expect(json_response.size).to eq(2)
|
|
|
|
expect(json_response.first['id']).to eq(another_merge_request.id)
|
|
|
|
expect(json_response.second['id']).to eq(merge_request.id)
|
|
|
|
end
|
2017-02-16 04:08:18 -05:00
|
|
|
end
|
2012-08-16 14:51:31 -04:00
|
|
|
end
|