Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
bc33f1bd
Commit
bc33f1bd
authored
Jun 08, 2019
by
Matija Čupić
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Gate MR head_pipeline behind read_pipeline ability
parent
e3eeb779
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
28 additions
and
1 deletion
+28
-1
lib/api/entities.rb
lib/api/entities.rb
+3
-1
spec/requests/api/merge_requests_spec.rb
spec/requests/api/merge_requests_spec.rb
+25
-0
No files found.
lib/api/entities.rb
View file @
bc33f1bd
...
...
@@ -735,7 +735,9 @@ module API
merge_request
.
metrics
&
.
pipeline
end
expose
:head_pipeline
,
using:
'API::Entities::Pipeline'
expose
:head_pipeline
,
using:
'API::Entities::Pipeline'
,
if:
->
(
_
,
options
)
do
Ability
.
allowed?
(
options
[
:current_user
],
:read_pipeline
,
options
[
:project
])
end
expose
:diff_refs
,
using:
Entities
::
DiffRefs
...
...
spec/requests/api/merge_requests_spec.rb
View file @
bc33f1bd
...
...
@@ -834,6 +834,31 @@ describe API::MergeRequests do
end
end
context
'head_pipeline'
do
before
do
merge_request
.
update
(
head_pipeline:
create
(
:ci_pipeline
))
merge_request
.
project
.
project_feature
.
update
(
builds_access_level:
10
)
end
context
'when user can read the pipeline'
do
it
'exposes pipeline information'
do
get
api
(
"/projects/
#{
project
.
id
}
/merge_requests/
#{
merge_request
.
iid
}
"
,
user
)
expect
(
json_response
).
to
include
(
'head_pipeline'
)
end
end
context
'when user can not read the pipeline'
do
let
(
:guest
)
{
create
(
:user
)
}
it
'does not expose pipeline information'
do
get
api
(
"/projects/
#{
project
.
id
}
/merge_requests/
#{
merge_request
.
iid
}
"
,
guest
)
expect
(
json_response
).
not_to
include
(
'head_pipeline'
)
end
end
end
it
'returns the commits behind the target branch when include_diverged_commits_count is present'
do
allow_any_instance_of
(
merge_request
.
class
).
to
receive
(
:diverged_commits_count
).
and_return
(
1
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment