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
7426e616
Commit
7426e616
authored
Jul 18, 2017
by
Lin Jen-Shin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make sure it checks against the tag only when it's a tag
parent
ef2e9879
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
1 deletion
+23
-1
app/policies/ci/build_policy.rb
app/policies/ci/build_policy.rb
+4
-1
spec/policies/ci/build_policy_spec.rb
spec/policies/ci/build_policy_spec.rb
+19
-0
No files found.
app/policies/ci/build_policy.rb
View file @
7426e616
...
...
@@ -5,8 +5,11 @@ module Ci
access
=
::
Gitlab
::
UserAccess
.
new
(
@user
,
project:
@subject
.
project
)
!
access
.
can_merge_to_branch?
(
@subject
.
ref
)
||
if
@subject
.
tag?
!
access
.
can_create_tag?
(
@subject
.
ref
)
else
!
access
.
can_merge_to_branch?
(
@subject
.
ref
)
end
end
rule
{
protected_action
}.
prevent
:update_build
...
...
spec/policies/ci/build_policy_spec.rb
View file @
7426e616
...
...
@@ -138,11 +138,30 @@ describe Ci::BuildPolicy, :models do
before
do
create
(
:protected_tag
,
:no_one_can_create
,
name:
'some-ref'
,
project:
project
)
build
.
update
(
tag:
true
)
end
it_behaves_like
'protected ref'
end
context
'when build is against a protected tag but it is not a tag'
do
before
do
create
(
:protected_tag
,
:no_one_can_create
,
name:
'some-ref'
,
project:
project
)
end
context
'when build is a manual action'
do
let
(
:build
)
do
create
(
:ci_build
,
:manual
,
ref:
'some-ref'
,
pipeline:
pipeline
)
end
it
'includes ability to update build'
do
expect
(
policy
).
to
be_allowed
:update_build
end
end
end
context
'when branch build is assigned to is not protected'
do
context
'when build is a manual action'
do
let
(
:build
)
{
create
(
:ci_build
,
:manual
,
pipeline:
pipeline
)
}
...
...
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