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
624d6690
Commit
624d6690
authored
Mar 10, 2021
by
Nicky Gerritsen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allow updating merged results pipelines and merge trains via API
Changelog: changed
parent
7ddd6d28
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
170 additions
and
1 deletion
+170
-1
ee/lib/ee/api/entities/project.rb
ee/lib/ee/api/entities/project.rb
+2
-0
ee/lib/ee/api/helpers/projects_helpers.rb
ee/lib/ee/api/helpers/projects_helpers.rb
+5
-1
ee/lib/ee/api/projects.rb
ee/lib/ee/api/projects.rb
+8
-0
ee/spec/requests/api/projects_spec.rb
ee/spec/requests/api/projects_spec.rb
+150
-0
lib/api/helpers/projects_helpers.rb
lib/api/helpers/projects_helpers.rb
+3
-0
spec/requests/api/project_attributes.yml
spec/requests/api/project_attributes.yml
+2
-0
No files found.
ee/lib/ee/api/entities/project.rb
View file @
624d6690
...
...
@@ -39,6 +39,8 @@ module EE
end
expose
:issues_template
,
if:
->
(
project
,
_
)
{
project
.
feature_available?
(
:issuable_default_templates
)
}
expose
:merge_requests_template
,
if:
->
(
project
,
_
)
{
project
.
feature_available?
(
:issuable_default_templates
)
}
expose
:merge_pipelines_enabled?
,
as: :merge_pipelines_enabled
,
if:
->
(
project
,
_
)
{
project
.
feature_available?
(
:merge_pipelines
)
}
expose
:merge_trains_enabled?
,
as: :merge_trains_enabled
,
if:
->
(
project
,
_
)
{
project
.
feature_available?
(
:merge_pipelines
)
}
end
end
end
...
...
ee/lib/ee/api/helpers/projects_helpers.rb
View file @
624d6690
...
...
@@ -35,6 +35,8 @@ module EE
optional
:fallback_approvals_required
,
type:
Integer
,
desc:
'Overall approvals required when no rule is present'
optional
:issues_template
,
type:
String
,
desc:
'Default description for Issues. Description is parsed with GitLab Flavored Markdown.'
optional
:merge_requests_template
,
type:
String
,
desc:
'Default description for merge requests. Description is parsed with GitLab Flavored Markdown.'
optional
:merge_pipelines_enabled
,
type:
Grape
::
API
::
Boolean
,
desc:
'Enable merged results pipelines.'
optional
:merge_trains_enabled
,
type:
Grape
::
API
::
Boolean
,
desc:
'Enable merge trains.'
end
end
...
...
@@ -53,7 +55,9 @@ module EE
:fallback_approvals_required
,
:import_url
,
:issues_template
,
:merge_requests_template
:merge_requests_template
,
:merge_pipelines_enabled
,
:merge_trains_enabled
]
end
end
...
...
ee/lib/ee/api/projects.rb
View file @
624d6690
...
...
@@ -83,6 +83,7 @@ module EE
verify_mirror_attrs!
(
project
,
attrs
)
verify_issuable_default_templates_attrs!
(
project
,
attrs
)
verify_merge_pipelines_attrs!
(
project
,
attrs
)
end
def
verify_mirror_attrs!
(
project
,
attrs
)
...
...
@@ -100,6 +101,13 @@ module EE
end
end
def
verify_merge_pipelines_attrs!
(
project
,
attrs
)
return
if
can?
(
current_user
,
:admin_project
,
project
)
attrs
.
delete
(
:merge_pipelines_enabled
)
unless
project
.
feature_available?
(
:merge_pipelines
)
attrs
.
delete
(
:merge_trains_enabled
)
unless
project
.
feature_available?
(
:merge_trains
)
end
def
check_audit_events_available!
(
project
)
forbidden!
unless
project
.
feature_available?
(
:audit_events
)
end
...
...
ee/spec/requests/api/projects_spec.rb
View file @
624d6690
...
...
@@ -303,6 +303,60 @@ RSpec.describe API::Projects do
expect
(
json_response
).
not_to
have_key
'merge_requests_template'
end
end
context
'merge pipelines feature is available'
do
before
do
stub_licensed_features
(
merge_pipelines:
true
)
end
it
'returns merge pipelines enabled flag'
do
subject
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
json_response
).
to
have_key
'merge_pipelines_enabled'
end
end
context
'merge pipelines feature not available'
do
before
do
stub_licensed_features
(
merge_pipelines:
false
)
end
it
'does not return merge pipelines enabled flag'
do
subject
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
json_response
).
not_to
have_key
'merge_pipelines_enabled'
end
end
context
'merge trains feature is available'
do
before
do
stub_licensed_features
(
merge_pipelines:
true
,
merge_trains:
true
)
project
.
update!
(
merge_pipelines_enabled:
true
,
merge_trains_enabled:
true
)
stub_feature_flags
(
disable_merge_trains:
false
)
end
it
'returns merge trains enabled flag'
do
subject
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
json_response
).
to
have_key
'merge_trains_enabled'
end
end
context
'merge trains feature not available'
do
before
do
stub_licensed_features
(
merge_trains:
false
)
end
it
'does not return merge trains enabled flag'
do
subject
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
json_response
).
not_to
have_key
'merge_trains_enabled'
end
end
end
# Assumes the following variables are defined:
...
...
@@ -891,6 +945,102 @@ RSpec.describe API::Projects do
end
end
context
'merge pipelines feature is available'
do
before
do
stub_licensed_features
(
merge_pipelines:
true
)
end
let
(
:project_params
)
{
{
merge_pipelines_enabled:
true
}
}
it
'updates the content'
do
expect
{
subject
}.
to
change
{
project
.
reload
.
merge_pipelines_enabled
}
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
project
.
merge_pipelines_enabled
).
to
eq
(
project_params
[
:merge_pipelines_enabled
])
expect
(
json_response
[
'merge_pipelines_enabled'
]).
to
eq
(
project_params
[
:merge_pipelines_enabled
])
end
context
'when user does not have permission'
do
let
(
:developer_user
)
{
create
(
:user
)
}
before
do
project
.
add_developer
(
developer_user
)
end
it
'does not update the content'
do
expect
do
put
api
(
"/projects/
#{
project
.
id
}
"
,
developer_user
),
params:
project_params
end
.
not_to
change
{
project
.
reload
.
merge_pipelines_enabled
}
expect
(
response
).
to
have_gitlab_http_status
(
:forbidden
)
end
end
end
context
'merge pipelines feature feature not available'
do
before
do
stub_licensed_features
(
merge_pipelines:
false
)
end
let
(
:project_params
)
{
{
merge_pipelines_enabled:
true
}
}
it
'does not update the content'
do
subject
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
json_response
).
not_to
have_key
'merge_pipelines_enabled'
end
end
context
'merge trains feature is available'
do
before
do
stub_licensed_features
(
merge_pipelines:
true
,
merge_trains:
true
)
project
.
update!
(
merge_pipelines_enabled:
true
,
merge_trains_enabled:
false
)
stub_feature_flags
(
disable_merge_trains:
false
)
end
let
(
:project_params
)
{
{
merge_trains_enabled:
true
}
}
it
'updates the content'
do
expect
{
subject
}.
to
change
{
project
.
reload
.
merge_trains_enabled
}
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
project
.
merge_trains_enabled
).
to
eq
(
project_params
[
:merge_trains_enabled
])
expect
(
json_response
[
'merge_trains_enabled'
]).
to
eq
(
project_params
[
:merge_trains_enabled
])
end
context
'when user does not have permission'
do
let
(
:developer_user
)
{
create
(
:user
)
}
before
do
project
.
add_developer
(
developer_user
)
end
it
'does not update the content'
do
expect
do
put
api
(
"/projects/
#{
project
.
id
}
"
,
developer_user
),
params:
project_params
end
.
not_to
change
{
project
.
reload
.
merge_trains_enabled
}
expect
(
response
).
to
have_gitlab_http_status
(
:forbidden
)
end
end
end
context
'merge trains feature feature not available'
do
before
do
stub_licensed_features
(
merge_trains:
false
)
end
let
(
:project_params
)
{
{
merge_trains_enabled:
true
}
}
it
'does not update the content'
do
expect
{
subject
}.
not_to
change
{
project
.
merge_trains_enabled
}
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
json_response
).
not_to
have_key
'merge_trains_enabled'
end
end
context
'when updating external classification'
do
before
do
enable_external_authorization_service_check
...
...
lib/api/helpers/projects_helpers.rb
View file @
624d6690
...
...
@@ -132,7 +132,10 @@ module API
:forking_access_level
,
:issues_access_level
,
:lfs_enabled
,
:merge_pipelines_enabled
,
:merge_requests_access_level
,
:merge_requests_template
,
:merge_trains_enabled
,
:merge_method
,
:name
,
:only_allow_merge_if_all_discussions_are_resolved
,
...
...
spec/requests/api/project_attributes.yml
View file @
624d6690
...
...
@@ -89,6 +89,8 @@ ci_cd_settings:
-
group_runners_enabled
-
merge_pipelines_enabled
-
merge_trains_enabled
-
merge_pipelines_enabled
-
merge_trains_enabled
-
auto_rollback_enabled
remapped_attributes
:
default_git_depth
:
ci_default_git_depth
...
...
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