summaryrefslogtreecommitdiff
path: root/spec/requests/api
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2019-09-17 12:06:48 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2019-09-17 12:06:48 +0000
commitbd860c22f6a4b9473cbddd34a53eead8235a7ea1 (patch)
tree3f955a56c2ac90497863da26902a42dba49f3466 /spec/requests/api
parente567b4c2df7dc4085d213db029eff6b6fcde0152 (diff)
downloadgitlab-ce-bd860c22f6a4b9473cbddd34a53eead8235a7ea1.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/requests/api')
-rw-r--r--spec/requests/api/groups_spec.rb44
-rw-r--r--spec/requests/api/issues/get_group_issues_spec.rb4
-rw-r--r--spec/requests/api/issues/get_project_issues_spec.rb3
-rw-r--r--spec/requests/api/issues/issues_spec.rb85
-rw-r--r--spec/requests/api/pipelines_spec.rb48
-rw-r--r--spec/requests/api/projects_spec.rb1
6 files changed, 157 insertions, 28 deletions
diff --git a/spec/requests/api/groups_spec.rb b/spec/requests/api/groups_spec.rb
index 0893dcb39b6..b3acf531ccb 100644
--- a/spec/requests/api/groups_spec.rb
+++ b/spec/requests/api/groups_spec.rb
@@ -59,6 +59,16 @@ describe API::Groups do
.to satisfy_one { |group| group['name'] == group1.name }
end
+ it "does not include runners_token information" do
+ get api("/groups", user1)
+
+ expect(response).to have_gitlab_http_status(200)
+ expect(response).to include_pagination_headers
+ expect(json_response).to be_an Array
+ expect(json_response.length).to eq(1)
+ expect(json_response.first).not_to include('runners_token')
+ end
+
it "does not include statistics" do
get api("/groups", user1), params: { statistics: true }
@@ -79,6 +89,16 @@ describe API::Groups do
expect(json_response.length).to eq(2)
end
+ it "does not include runners_token information" do
+ get api("/groups", admin)
+
+ expect(response).to have_gitlab_http_status(200)
+ expect(response).to include_pagination_headers
+ expect(json_response).to be_an Array
+ expect(json_response.length).to eq(2)
+ expect(json_response.first).not_to include('runners_token')
+ end
+
it "does not include statistics by default" do
get api("/groups", admin)
@@ -292,6 +312,7 @@ describe API::Groups do
get api("/groups/#{group1.id}")
expect(response).to have_gitlab_http_status(200)
+ expect(json_response).not_to include('runners_token')
end
it 'returns only public projects in the group' do
@@ -350,6 +371,22 @@ describe API::Groups do
expect(response).to have_gitlab_http_status(200)
expect(json_response['projects']).to be_nil
expect(json_response['shared_projects']).to be_nil
+ expect(json_response).not_to include('runners_token')
+ end
+
+ it "doesn't return runners_token if the user is not the owner of the group" do
+ get api("/groups/#{group1.id}", user3)
+
+ expect(response).to have_gitlab_http_status(200)
+ expect(json_response).not_to include('runners_token')
+ end
+
+ it "returns runners_token if the user is the owner of the group" do
+ group1.add_owner(user3)
+ get api("/groups/#{group1.id}", user3)
+
+ expect(response).to have_gitlab_http_status(200)
+ expect(json_response).to include('runners_token')
end
it "does not return a non existing group" do
@@ -407,6 +444,13 @@ describe API::Groups do
expect(json_response['name']).to eq(group2.name)
end
+ it "returns information of the runners_token for the group" do
+ get api("/groups/#{group2.id}", admin)
+
+ expect(response).to have_gitlab_http_status(200)
+ expect(json_response).to include('runners_token')
+ end
+
it "does not return a non existing group" do
get api("/groups/1328", admin)
diff --git a/spec/requests/api/issues/get_group_issues_spec.rb b/spec/requests/api/issues/get_group_issues_spec.rb
index c487471e4a1..3ee08758f99 100644
--- a/spec/requests/api/issues/get_group_issues_spec.rb
+++ b/spec/requests/api/issues/get_group_issues_spec.rb
@@ -437,17 +437,21 @@ describe API::Issues do
end
context 'with labeled issues' do
+ let(:group_issue2) { create :issue, project: group_project }
let(:label_b) { create(:label, title: 'foo', project: group_project) }
let(:label_c) { create(:label, title: 'bar', project: group_project) }
before do
+ create(:label_link, label: group_label, target: group_issue2)
create(:label_link, label: label_b, target: group_issue)
+ create(:label_link, label: label_b, target: group_issue2)
create(:label_link, label: label_c, target: group_issue)
get api(base_url, user), params: params
end
let(:issue) { group_issue }
+ let(:issue2) { group_issue2 }
let(:label) { group_label }
it_behaves_like 'labeled issues with labels and label_name params'
diff --git a/spec/requests/api/issues/get_project_issues_spec.rb b/spec/requests/api/issues/get_project_issues_spec.rb
index b7aa3f93451..c10f5b2bd58 100644
--- a/spec/requests/api/issues/get_project_issues_spec.rb
+++ b/spec/requests/api/issues/get_project_issues_spec.rb
@@ -283,11 +283,14 @@ describe API::Issues do
end
context 'with labeled issues' do
+ let(:issue2) { create :issue, project: project }
let(:label_b) { create(:label, title: 'foo', project: project) }
let(:label_c) { create(:label, title: 'bar', project: project) }
before do
+ create(:label_link, label: label, target: issue2)
create(:label_link, label: label_b, target: issue)
+ create(:label_link, label: label_b, target: issue2)
create(:label_link, label: label_c, target: issue)
get api('/issues', user), params: params
diff --git a/spec/requests/api/issues/issues_spec.rb b/spec/requests/api/issues/issues_spec.rb
index f19c2dcc6fe..61a94b682be 100644
--- a/spec/requests/api/issues/issues_spec.rb
+++ b/spec/requests/api/issues/issues_spec.rb
@@ -427,9 +427,12 @@ describe API::Issues do
context 'with labeled issues' do
let(:label_b) { create(:label, title: 'foo', project: project) }
let(:label_c) { create(:label, title: 'bar', project: project) }
+ let(:issue2) { create(:issue, author: user, project: project) }
before do
+ create(:label_link, label: label, target: issue2)
create(:label_link, label: label_b, target: issue)
+ create(:label_link, label: label_b, target: issue2)
create(:label_link, label: label_c, target: issue)
get api('/issues', user), params: params
@@ -497,46 +500,74 @@ describe API::Issues do
end
end
- it 'returns an empty array if no issue matches milestone' do
- get api("/issues?milestone=#{empty_milestone.title}", user)
+ context 'filter by milestone' do
+ it 'returns an empty array if no issue matches milestone' do
+ get api("/issues?milestone=#{empty_milestone.title}", user)
- expect_paginated_array_response([])
- end
+ expect_paginated_array_response([])
+ end
- it 'returns an empty array if milestone does not exist' do
- get api('/issues?milestone=foo', user)
+ it 'returns an empty array if milestone does not exist' do
+ get api('/issues?milestone=foo', user)
- expect_paginated_array_response([])
- end
+ expect_paginated_array_response([])
+ end
- it 'returns an array of issues in given milestone' do
- get api("/issues?milestone=#{milestone.title}", user)
+ it 'returns an array of issues in given milestone' do
+ get api("/issues?milestone=#{milestone.title}", user)
- expect_paginated_array_response([issue.id, closed_issue.id])
- end
+ expect_paginated_array_response([issue.id, closed_issue.id])
+ end
- it 'returns an array of issues in given milestone_title param' do
- get api("/issues?milestone_title=#{milestone.title}", user)
+ it 'returns an array of issues in given milestone_title param' do
+ get api("/issues?milestone_title=#{milestone.title}", user)
- expect_paginated_array_response([issue.id, closed_issue.id])
- end
+ expect_paginated_array_response([issue.id, closed_issue.id])
+ end
- it 'returns an array of issues matching state in milestone' do
- get api("/issues?milestone=#{milestone.title}&state=closed", user)
+ it 'returns an array of issues matching state in milestone' do
+ get api("/issues?milestone=#{milestone.title}&state=closed", user)
- expect_paginated_array_response(closed_issue.id)
- end
+ expect_paginated_array_response(closed_issue.id)
+ end
- it 'returns an array of issues with no milestone' do
- get api("/issues?milestone=#{no_milestone_title}", author)
+ it 'returns an array of issues with no milestone' do
+ get api("/issues?milestone=#{no_milestone_title}", author)
- expect_paginated_array_response(confidential_issue.id)
- end
+ expect_paginated_array_response(confidential_issue.id)
+ end
- it 'returns an array of issues with no milestone using milestone_title param' do
- get api("/issues?milestone_title=#{no_milestone_title}", author)
+ it 'returns an array of issues with no milestone using milestone_title param' do
+ get api("/issues?milestone_title=#{no_milestone_title}", author)
- expect_paginated_array_response(confidential_issue.id)
+ expect_paginated_array_response(confidential_issue.id)
+ end
+
+ context 'negated' do
+ it 'returns all issues if milestone does not exist' do
+ get api('/issues?not[milestone]=foo', user)
+
+ expect_paginated_array_response([issue.id, closed_issue.id])
+ end
+
+ it 'returns all issues that do not belong to a milestone but have a milestone' do
+ get api("/issues?not[milestone]=#{empty_milestone.title}", user)
+
+ expect_paginated_array_response([issue.id, closed_issue.id])
+ end
+
+ it 'returns an array of issues with any milestone' do
+ get api("/issues?not[milestone]=#{no_milestone_title}", user)
+
+ expect_paginated_array_response([issue.id, closed_issue.id])
+ end
+
+ it 'returns an array of issues matching state not in milestone' do
+ get api("/issues?not[milestone]=#{empty_milestone.title}&state=closed", user)
+
+ expect_paginated_array_response(closed_issue.id)
+ end
+ end
end
it 'returns an array of issues found by iids' do
diff --git a/spec/requests/api/pipelines_spec.rb b/spec/requests/api/pipelines_spec.rb
index 174b3214d13..3a3f0e970a4 100644
--- a/spec/requests/api/pipelines_spec.rb
+++ b/spec/requests/api/pipelines_spec.rb
@@ -459,6 +459,54 @@ describe API::Pipelines do
end
end
+ describe 'GET /projects/:id/pipelines/latest' do
+ context 'authorized user' do
+ let(:second_branch) { project.repository.branches[2] }
+
+ let!(:second_pipeline) do
+ create(:ci_empty_pipeline, project: project, sha: second_branch.target,
+ ref: second_branch.name, user: user)
+ end
+
+ before do
+ create(:ci_empty_pipeline, project: project, sha: project.commit.parent.id,
+ ref: project.default_branch, user: user)
+ end
+
+ context 'default repository branch' do
+ it 'gets the latest pipleine' do
+ get api("/projects/#{project.id}/pipelines/latest", user)
+
+ expect(response).to have_gitlab_http_status(200)
+ expect(response).to match_response_schema('public_api/v4/pipeline/detail')
+ expect(json_response['ref']).to eq(project.default_branch)
+ expect(json_response['sha']).to eq(project.commit.id)
+ end
+ end
+
+ context 'ref parameter' do
+ it 'gets the latest pipleine' do
+ get api("/projects/#{project.id}/pipelines/latest", user), params: { ref: second_branch.name }
+
+ expect(response).to have_gitlab_http_status(200)
+ expect(response).to match_response_schema('public_api/v4/pipeline/detail')
+ expect(json_response['ref']).to eq(second_branch.name)
+ expect(json_response['sha']).to eq(second_branch.target)
+ end
+ end
+ end
+
+ context 'unauthorized user' do
+ it 'does not return a project pipeline' do
+ get api("/projects/#{project.id}/pipelines/#{pipeline.id}", non_member)
+
+ expect(response).to have_gitlab_http_status(404)
+ expect(json_response['message']).to eq '404 Project Not Found'
+ expect(json_response['id']).to be nil
+ end
+ end
+ end
+
describe 'GET /projects/:id/pipelines/:pipeline_id/variables' do
subject { get api("/projects/#{project.id}/pipelines/#{pipeline.id}/variables", api_user) }
diff --git a/spec/requests/api/projects_spec.rb b/spec/requests/api/projects_spec.rb
index f52e36e6bcd..2d8ef9c06dc 100644
--- a/spec/requests/api/projects_spec.rb
+++ b/spec/requests/api/projects_spec.rb
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
require 'spec_helper'
shared_examples 'languages and percentages JSON response' do