BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
005870d5
Commit
005870d5
authored
Jul 04, 2017
by
Lin Jen-Shin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix bad conflict resolution
parent
39573c6d
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
21 additions
and
19 deletions
+21
-19
pipeline_policy.rb
app/policies/ci/pipeline_policy.rb
+1
-1
create_pipeline_service.rb
app/services/ci/create_pipeline_service.rb
+12
-10
build_policy_spec.rb
spec/policies/ci/build_policy_spec.rb
+3
-3
pipeline_policy_spec.rb
spec/policies/ci/pipeline_policy_spec.rb
+5
-5
No files found.
app/policies/ci/pipeline_policy.rb
View file @
005870d5
module
Ci
class
PipelinePolicy
<
BasePolicy
delegate
{
pipeline
.
project
}
delegate
{
@subject
.
project
}
condition
(
:user_cannot_update
)
do
!::
Gitlab
::
UserAccess
...
...
app/services/ci/create_pipeline_service.rb
View file @
005870d5
...
...
@@ -51,19 +51,13 @@ module Ci
return
error
(
'No stages / jobs for this pipeline.'
)
end
process!
process!
do
pipeline_created_counter
.
increment
(
source:
source
)
end
end
private
def
triggering_user_allowed_for_ref?
(
trigger_request
,
ref
)
triggering_user
=
current_user
||
trigger_request
.
trigger
.
owner
(
triggering_user
&&
Ci
::
Pipeline
.
allowed_to_create?
(
triggering_user
,
project
,
ref
))
||
!
project
.
protected_for?
(
ref
)
end
def
process!
Ci
::
Pipeline
.
transaction
do
update_merge_requests_head_pipeline
if
pipeline
.
save
...
...
@@ -75,11 +69,19 @@ module Ci
cancel_pending_pipelines
if
project
.
auto_cancel_pending_pipelines?
pipeline_created_counter
.
increment
(
source:
source
)
yield
pipeline
.
tap
(
&
:process!
)
end
def
triggering_user_allowed_for_ref?
(
trigger_request
,
ref
)
triggering_user
=
current_user
||
trigger_request
.
trigger
.
owner
(
triggering_user
&&
Ci
::
Pipeline
.
allowed_to_create?
(
triggering_user
,
project
,
ref
))
||
!
project
.
protected_for?
(
ref
)
end
def
update_merge_requests_head_pipeline
return
unless
pipeline
.
latest?
...
...
spec/policies/ci/build_policy_spec.rb
View file @
005870d5
...
...
@@ -110,7 +110,7 @@ describe Ci::BuildPolicy, :models do
let
(
:branch_policy
)
{
:no_one_can_push
}
it
'does not include ability to update build'
do
expect
(
polic
ies
).
to
be_disallowed
:update_build
expect
(
polic
y
).
to
be_disallowed
:update_build
end
end
...
...
@@ -118,7 +118,7 @@ describe Ci::BuildPolicy, :models do
let
(
:branch_policy
)
{
:developers_can_push
}
it
'includes ability to update build'
do
expect
(
polic
ies
).
to
be_allowed
:update_build
expect
(
polic
y
).
to
be_allowed
:update_build
end
end
...
...
@@ -126,7 +126,7 @@ describe Ci::BuildPolicy, :models do
let
(
:branch_policy
)
{
:developers_can_merge
}
it
'includes ability to update build'
do
expect
(
polic
ies
).
to
be_allowed
:update_build
expect
(
polic
y
).
to
be_allowed
:update_build
end
end
end
...
...
spec/policies/ci/pipeline_policy_spec.rb
View file @
005870d5
...
...
@@ -4,8 +4,8 @@ describe Ci::PipelinePolicy, :models do
let
(
:user
)
{
create
(
:user
)
}
let
(
:pipeline
)
{
create
(
:ci_empty_pipeline
,
project:
project
)
}
let
(
:polic
ies
)
do
described_class
.
abilities
(
user
,
pipeline
).
to_set
let
(
:polic
y
)
do
described_class
.
new
(
user
,
pipeline
)
end
describe
'rules'
do
...
...
@@ -23,7 +23,7 @@ describe Ci::PipelinePolicy, :models do
let
(
:branch_policy
)
{
:no_one_can_push
}
it
'does not include ability to update pipeline'
do
expect
(
polic
ies
).
to
be_disallowed
:update_pipeline
expect
(
polic
y
).
to
be_disallowed
:update_pipeline
end
end
...
...
@@ -31,7 +31,7 @@ describe Ci::PipelinePolicy, :models do
let
(
:branch_policy
)
{
:developers_can_push
}
it
'includes ability to update pipeline'
do
expect
(
polic
ies
).
to
be_allowed
:update_pipeline
expect
(
polic
y
).
to
be_allowed
:update_pipeline
end
end
...
...
@@ -39,7 +39,7 @@ describe Ci::PipelinePolicy, :models do
let
(
:branch_policy
)
{
:developers_can_merge
}
it
'includes ability to update pipeline'
do
expect
(
polic
ies
).
to
be_allowed
:update_pipeline
expect
(
polic
y
).
to
be_allowed
:update_pipeline
end
end
end
...
...
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