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
a8e29934
Commit
a8e29934
authored
6 years ago
by
Mark Chao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update project's fallback_approvals_required
Use existing project PUT to update
parent
6054912f
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
3 additions
and
59 deletions
+3
-59
ee/app/models/ee/project.rb
ee/app/models/ee/project.rb
+2
-0
ee/lib/api/project_approval_rules.rb
ee/lib/api/project_approval_rules.rb
+0
-23
ee/lib/ee/api/projects.rb
ee/lib/ee/api/projects.rb
+1
-0
ee/spec/requests/api/project_approval_rules_spec.rb
ee/spec/requests/api/project_approval_rules_spec.rb
+0
-36
No files found.
ee/app/models/ee/project.rb
View file @
a8e29934
...
@@ -120,6 +120,8 @@ module EE
...
@@ -120,6 +120,8 @@ module EE
accepts_nested_attributes_for
:tracing_setting
,
update_only:
true
,
allow_destroy:
true
accepts_nested_attributes_for
:tracing_setting
,
update_only:
true
,
allow_destroy:
true
accepts_nested_attributes_for
:alerting_setting
,
update_only:
true
accepts_nested_attributes_for
:alerting_setting
,
update_only:
true
alias_attribute
:fallback_approvals_required
,
:approvals_before_merge
end
end
class_methods
do
class_methods
do
...
...
This diff is collapsed.
Click to expand it.
ee/lib/api/project_approval_rules.rb
View file @
a8e29934
...
@@ -22,29 +22,6 @@ module API
...
@@ -22,29 +22,6 @@ module API
present
user_project
,
with:
EE
::
API
::
Entities
::
ProjectApprovalRules
,
current_user:
current_user
present
user_project
,
with:
EE
::
API
::
Entities
::
ProjectApprovalRules
,
current_user:
current_user
end
end
desc
'Update fallback approvals required'
do
detail
'Private API subject to change'
success
::
API
::
Entities
::
Project
end
params
do
requires
:fallback_approvals_required
,
as: :approvals_before_merge
,
type:
Integer
,
desc:
'The total number of required approvals in case of fallback'
end
put
do
authorize!
:admin_project
,
user_project
result
=
::
Projects
::
UpdateService
.
new
(
user_project
,
current_user
,
declared_params
).
execute
if
result
[
:status
]
==
:success
present
(
user_project
,
with:
::
API
::
Entities
::
Project
,
user_can_admin_project:
can?
(
current_user
,
:admin_project
,
user_project
)
)
else
render_validation_error!
(
user_project
)
end
end
segment
'rules'
do
segment
'rules'
do
desc
'Create new approval rule'
do
desc
'Create new approval rule'
do
detail
'Private API subject to change'
detail
'Private API subject to change'
...
...
This diff is collapsed.
Click to expand it.
ee/lib/ee/api/projects.rb
View file @
a8e29934
...
@@ -20,6 +20,7 @@ module EE
...
@@ -20,6 +20,7 @@ module EE
optional
:mirror_overwrites_diverged_branches
,
type:
Grape
::
API
::
Boolean
,
desc:
'Pull mirror overwrites diverged branches'
optional
:mirror_overwrites_diverged_branches
,
type:
Grape
::
API
::
Boolean
,
desc:
'Pull mirror overwrites diverged branches'
optional
:import_url
,
type:
String
,
desc:
'URL from which the project is imported'
optional
:import_url
,
type:
String
,
desc:
'URL from which the project is imported'
optional
:packages_enabled
,
type:
Grape
::
API
::
Boolean
,
desc:
'Enable project packages feature'
optional
:packages_enabled
,
type:
Grape
::
API
::
Boolean
,
desc:
'Enable project packages feature'
optional
:fallback_approvals_required
,
type:
Integer
,
desc:
'Overall approvals required when no rule is present'
end
end
def
apply_filters
(
projects
)
def
apply_filters
(
projects
)
...
...
This diff is collapsed.
Click to expand it.
ee/spec/requests/api/project_approval_rules_spec.rb
View file @
a8e29934
...
@@ -74,42 +74,6 @@ describe API::ProjectApprovalRules do
...
@@ -74,42 +74,6 @@ describe API::ProjectApprovalRules do
end
end
end
end
describe
'PUT /projects/:id/approval_settings'
do
let
(
:url
)
{
"/projects/
#{
project
.
id
}
/approval_settings"
}
shared_examples_for
'a user with access'
do
context
'when sending json data'
do
it
'updates approvals_before_merge'
do
expect
do
put
api
(
url
,
current_user
),
params:
{
fallback_approvals_required:
1
}.
to_json
,
headers:
{
CONTENT_TYPE
:
'application/json'
}
end
.
to
change
{
project
.
reload
.
approvals_before_merge
}.
from
(
0
).
to
(
1
)
expect
(
response
).
to
have_gitlab_http_status
(
200
)
end
end
end
context
'as a project admin'
do
it_behaves_like
'a user with access'
do
let
(
:current_user
)
{
user
}
end
end
context
'as a global admin'
do
it_behaves_like
'a user with access'
do
let
(
:current_user
)
{
admin
}
end
end
context
'as a random user'
do
it
'returns 403'
do
put
api
(
url
,
user2
),
{
fallback_approvals_required:
1
}.
to_json
,
{
CONTENT_TYPE
:
'application/json'
}
expect
(
response
).
to
have_gitlab_http_status
(
403
)
end
end
end
describe
'POST /projects/:id/approval_settings/rules'
do
describe
'POST /projects/:id/approval_settings/rules'
do
let
(
:current_user
)
{
user
}
let
(
:current_user
)
{
user
}
let
(
:params
)
do
let
(
:params
)
do
...
...
This diff is collapsed.
Click to expand it.
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