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
1b14182f
Commit
1b14182f
authored
Dec 27, 2016
by
Grzegorz Bizon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Expose stage dropdown path and title in stage entity
parent
f9331db1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
34 additions
and
5 deletions
+34
-5
stage_entity.rb
app/serializers/stage_entity.rb
+23
-5
stage_entity_spec.rb
spec/serializers/stage_entity_spec.rb
+11
-0
No files found.
app/serializers/stage_entity.rb
View file @
1b14182f
...
...
@@ -3,17 +3,35 @@ class StageEntity < Grape::Entity
expose
:name
expose
:status
do
|
stage
,
options
|
StatusEntity
.
represent
(
stage
.
detailed_status
(
request
.
user
),
options
)
expose
:title
do
|
stage
|
"
#{
stage
.
name
}
:
#{
detailed_status
.
label
}
"
end
expose
:detailed_status
,
as: :status
,
with:
StatusEntity
expose
:path
do
|
stage
|
namespace_project_pipeline_path
(
stage
.
pipeline
.
project
.
namespace
,
stage
.
pipeline
.
project
,
stage
.
pipeline
.
id
,
stage
.
pipeline
,
anchor:
stage
.
name
)
end
expose
:dropdown_path
do
|
stage
|
stage_namespace_project_pipeline_path
(
stage
.
pipeline
.
project
.
namespace
,
stage
.
pipeline
.
project
,
stage
.
pipeline
,
stage:
stage
.
name
,
format: :json
)
end
private
alias_method
:stage
,
:object
def
detailed_status
stage
.
detailed_status
(
request
.
user
)
end
end
spec/serializers/stage_entity_spec.rb
View file @
1b14182f
...
...
@@ -15,6 +15,7 @@ describe StageEntity do
before
do
allow
(
request
).
to
receive
(
:user
).
and_return
(
user
)
create
(
:ci_build
,
:success
,
pipeline:
pipeline
)
end
describe
'#as_json'
do
...
...
@@ -26,6 +27,7 @@ describe StageEntity do
it
'contains detailed status'
do
expect
(
subject
[
:status
]).
to
include
:text
,
:label
,
:group
,
:icon
expect
(
subject
[
:status
][
:label
]).
to
eq
'passed'
end
it
'contains valid name'
do
...
...
@@ -36,5 +38,14 @@ describe StageEntity do
expect
(
subject
[
:path
])
.
to
include
"pipelines/
#{
pipeline
.
id
}
#
#{
stage
.
name
}
"
end
it
'contains path to the stage dropdown'
do
expect
(
subject
[
:dropdown_path
])
.
to
include
"pipelines/
#{
pipeline
.
id
}
/stage.json?stage=test"
end
it
'contains stage title'
do
expect
(
subject
[
:title
]).
to
eq
'test: passed'
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