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
3dbef510
Commit
3dbef510
authored
Apr 06, 2017
by
Grzegorz Bizon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Expose manual action abilities from a build entity
parent
5525db8b
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
33 additions
and
5 deletions
+33
-5
app/serializers/build_entity.rb
app/serializers/build_entity.rb
+7
-3
spec/serializers/build_entity_spec.rb
spec/serializers/build_entity_spec.rb
+26
-2
No files found.
app/serializers/build_entity.rb
View file @
3dbef510
...
@@ -12,7 +12,7 @@ class BuildEntity < Grape::Entity
...
@@ -12,7 +12,7 @@ class BuildEntity < Grape::Entity
path_to
(
:retry_namespace_project_build
,
build
)
path_to
(
:retry_namespace_project_build
,
build
)
end
end
expose
:play_path
,
if:
->
(
build
,
_
)
{
build
.
playable?
}
do
|
build
|
expose
:play_path
,
if:
proc
{
playable?
}
do
|
build
|
path_to
(
:play_namespace_project_build
,
build
)
path_to
(
:play_namespace_project_build
,
build
)
end
end
...
@@ -25,11 +25,15 @@ class BuildEntity < Grape::Entity
...
@@ -25,11 +25,15 @@ class BuildEntity < Grape::Entity
alias_method
:build
,
:object
alias_method
:build
,
:object
def
p
ath_to
(
route
,
build
)
def
p
layable?
send
(
"
#{
route
}
_path"
,
build
.
project
.
namespace
,
build
.
project
,
build
)
build
.
playable?
&&
build
.
can_play?
(
request
.
user
)
end
end
def
detailed_status
def
detailed_status
build
.
detailed_status
(
request
.
user
)
build
.
detailed_status
(
request
.
user
)
end
end
def
path_to
(
route
,
build
)
send
(
"
#{
route
}
_path"
,
build
.
project
.
namespace
,
build
.
project
,
build
)
end
end
end
spec/serializers/build_entity_spec.rb
View file @
3dbef510
...
@@ -41,13 +41,37 @@ describe BuildEntity do
...
@@ -41,13 +41,37 @@ describe BuildEntity do
it
'does not contain path to play action'
do
it
'does not contain path to play action'
do
expect
(
subject
).
not_to
include
(
:play_path
)
expect
(
subject
).
not_to
include
(
:play_path
)
end
end
it
'is not a playable job'
do
expect
(
subject
[
:playable
]).
to
be
false
end
end
end
context
'when build is a manual action'
do
context
'when build is a manual action'
do
let
(
:build
)
{
create
(
:ci_build
,
:manual
)
}
let
(
:build
)
{
create
(
:ci_build
,
:manual
)
}
context
'when user is allowed to trigger action'
do
before
do
build
.
project
.
add_master
(
user
)
end
it
'contains path to play action'
do
it
'contains path to play action'
do
expect
(
subject
).
to
include
(
:play_path
)
expect
(
subject
).
to
include
(
:play_path
)
end
end
it
'is a playable action'
do
expect
(
subject
[
:playable
]).
to
be
true
end
end
context
'when user is not allowed to trigger action'
do
it
'does not contain path to play action'
do
expect
(
subject
).
not_to
include
(
:play_path
)
end
it
'is not a playable action'
do
expect
(
subject
[
:playable
]).
to
be
false
end
end
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