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
0
Merge Requests
0
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
Léo-Paul Géneau
gitlab-ce
Commits
6c6bc400
Commit
6c6bc400
authored
Apr 12, 2017
by
Grzegorz Bizon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move code for playing an action to separate service
parent
b09465f3
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
21 additions
and
13 deletions
+21
-13
app/models/ci/build.rb
app/models/ci/build.rb
+3
-12
app/policies/ci/build_policy.rb
app/policies/ci/build_policy.rb
+1
-1
app/services/ci/play_build_service.rb
app/services/ci/play_build_service.rb
+17
-0
No files found.
app/models/ci/build.rb
View file @
6c6bc400
...
@@ -122,18 +122,9 @@ module Ci
...
@@ -122,18 +122,9 @@ module Ci
end
end
def
play
(
current_user
)
def
play
(
current_user
)
unless
can_play?
(
current_user
)
Ci
::
PlayBuildService
raise
Gitlab
::
Access
::
AccessDeniedError
.
new
(
project
,
current_user
)
end
.
execute
(
self
)
# Try to queue a current build
if
self
.
enqueue
self
.
update
(
user:
current_user
)
self
else
# Otherwise we need to create a duplicate
Ci
::
Build
.
retry
(
self
,
current_user
)
end
end
end
def
cancelable?
def
cancelable?
...
...
app/policies/ci/build_policy.rb
View file @
6c6bc400
...
@@ -17,7 +17,7 @@ module Ci
...
@@ -17,7 +17,7 @@ module Ci
alias_method
:build
,
:subject
alias_method
:build
,
:subject
def
can_play_action?
def
can_play_action?
return
false
unless
build
.
playable
?
return
false
unless
build
.
action
?
::
Gitlab
::
UserAccess
::
Gitlab
::
UserAccess
.
new
(
user
,
project:
build
.
project
)
.
new
(
user
,
project:
build
.
project
)
...
...
app/services/ci/play_build_service.rb
0 → 100644
View file @
6c6bc400
module
Ci
class
PlayBuildService
<
::
BaseService
def
execute
(
build
)
unless
can?
(
current_user
,
:play_build
,
build
)
raise
Gitlab
::
Access
::
AccessDeniedError
end
# Try to enqueue thebuild, otherwise create a duplicate.
#
if
build
.
enqueue
build
.
tap
{
|
action
|
action
.
update
(
user:
current_user
)
}
else
Ci
::
Build
.
retry
(
build
,
current_user
)
end
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