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
d03e6878
Commit
d03e6878
authored
Jun 07, 2017
by
Kamil Trzcinski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rename BuildEntity to JobEntity
parent
0a80e504
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
41 additions
and
20 deletions
+41
-20
app/serializers/build_details_entity.rb
app/serializers/build_details_entity.rb
+1
-1
app/serializers/build_serializer.rb
app/serializers/build_serializer.rb
+1
-1
app/serializers/deployment_entity.rb
app/serializers/deployment_entity.rb
+2
-2
app/serializers/job_entity.rb
app/serializers/job_entity.rb
+2
-2
app/serializers/job_group_entity.rb
app/serializers/job_group_entity.rb
+1
-1
spec/serializers/build_details_entity_spec.rb
spec/serializers/build_details_entity_spec.rb
+2
-2
spec/serializers/job_entity_spec.rb
spec/serializers/job_entity_spec.rb
+32
-11
No files found.
app/serializers/build_details_entity.rb
View file @
d03e6878
class
BuildDetailsEntity
<
Build
Entity
class
BuildDetailsEntity
<
Job
Entity
expose
:coverage
,
:erased_at
,
:duration
expose
:coverage
,
:erased_at
,
:duration
expose
:tag_list
,
as: :tags
expose
:tag_list
,
as: :tags
...
...
app/serializers/build_serializer.rb
View file @
d03e6878
class
BuildSerializer
<
BaseSerializer
class
BuildSerializer
<
BaseSerializer
entity
Build
Entity
entity
Job
Entity
def
represent_status
(
resource
)
def
represent_status
(
resource
)
data
=
represent
(
resource
,
{
only:
[
:status
]
})
data
=
represent
(
resource
,
{
only:
[
:status
]
})
...
...
app/serializers/deployment_entity.rb
View file @
d03e6878
...
@@ -24,6 +24,6 @@ class DeploymentEntity < Grape::Entity
...
@@ -24,6 +24,6 @@ class DeploymentEntity < Grape::Entity
expose
:user
,
using:
UserEntity
expose
:user
,
using:
UserEntity
expose
:commit
,
using:
CommitEntity
expose
:commit
,
using:
CommitEntity
expose
:deployable
,
using:
Build
Entity
expose
:deployable
,
using:
Job
Entity
expose
:manual_actions
,
using:
Build
Entity
expose
:manual_actions
,
using:
Job
Entity
end
end
app/serializers/
build
_entity.rb
→
app/serializers/
job
_entity.rb
View file @
d03e6878
class
Build
Entity
<
Grape
::
Entity
class
Job
Entity
<
Grape
::
Entity
include
RequestAwareEntity
include
RequestAwareEntity
expose
:id
expose
:id
expose
:name
expose
:name
expose
:build_path
do
|
build
|
expose
:build_path
do
|
build
|
build
.
external
_url
||
path_to
(
:namespace_project_job
,
build
)
build
.
target
_url
||
path_to
(
:namespace_project_job
,
build
)
end
end
expose
:retry_path
,
if:
->
(
*
)
{
retryable?
}
do
|
build
|
expose
:retry_path
,
if:
->
(
*
)
{
retryable?
}
do
|
build
|
...
...
app/serializers/job_group_entity.rb
View file @
d03e6878
...
@@ -4,7 +4,7 @@ class JobGroupEntity < Grape::Entity
...
@@ -4,7 +4,7 @@ class JobGroupEntity < Grape::Entity
expose
:name
expose
:name
expose
:size
expose
:size
expose
:detailed_status
,
as: :status
,
with:
StatusEntity
expose
:detailed_status
,
as: :status
,
with:
StatusEntity
expose
:jobs
,
with:
Build
Entity
expose
:jobs
,
with:
Job
Entity
private
private
...
...
spec/serializers/build_details_entity_spec.rb
View file @
d03e6878
...
@@ -3,8 +3,8 @@ require 'spec_helper'
...
@@ -3,8 +3,8 @@ require 'spec_helper'
describe
BuildDetailsEntity
do
describe
BuildDetailsEntity
do
set
(
:user
)
{
create
(
:admin
)
}
set
(
:user
)
{
create
(
:admin
)
}
it
'inherits from
Build
Entity'
do
it
'inherits from
Job
Entity'
do
expect
(
described_class
).
to
be
<
Build
Entity
expect
(
described_class
).
to
be
<
Job
Entity
end
end
describe
'#as_json'
do
describe
'#as_json'
do
...
...
spec/serializers/
build
_entity_spec.rb
→
spec/serializers/
job
_entity_spec.rb
View file @
d03e6878
require
'spec_helper'
require
'spec_helper'
describe
Build
Entity
do
describe
Job
Entity
do
let
(
:user
)
{
create
(
:user
)
}
let
(
:user
)
{
create
(
:user
)
}
let
(
:
build
)
{
create
(
:ci_build
)
}
let
(
:
job
)
{
create
(
:ci_build
)
}
let
(
:project
)
{
build
.
project
}
let
(
:project
)
{
job
.
project
}
let
(
:request
)
{
double
(
'request'
)
}
let
(
:request
)
{
double
(
'request'
)
}
before
do
before
do
...
@@ -12,12 +12,12 @@ describe BuildEntity do
...
@@ -12,12 +12,12 @@ describe BuildEntity do
end
end
let
(
:entity
)
do
let
(
:entity
)
do
described_class
.
new
(
build
,
request:
request
)
described_class
.
new
(
job
,
request:
request
)
end
end
subject
{
entity
.
as_json
}
subject
{
entity
.
as_json
}
it
'contains paths to
build
page action'
do
it
'contains paths to
job
page action'
do
expect
(
subject
).
to
include
(
:build_path
)
expect
(
subject
).
to
include
(
:build_path
)
end
end
...
@@ -27,7 +27,7 @@ describe BuildEntity do
...
@@ -27,7 +27,7 @@ describe BuildEntity do
end
end
it
'contains whether it is playable'
do
it
'contains whether it is playable'
do
expect
(
subject
[
:playable
]).
to
eq
build
.
playable?
expect
(
subject
[
:playable
]).
to
eq
job
.
playable?
end
end
it
'contains timestamps'
do
it
'contains timestamps'
do
...
@@ -41,7 +41,7 @@ describe BuildEntity do
...
@@ -41,7 +41,7 @@ describe BuildEntity do
context
'when build is retryable'
do
context
'when build is retryable'
do
before
do
before
do
build
.
update
(
status: :failed
)
job
.
update
(
status: :failed
)
end
end
it
'contains cancel path'
do
it
'contains cancel path'
do
...
@@ -51,7 +51,7 @@ describe BuildEntity do
...
@@ -51,7 +51,7 @@ describe BuildEntity do
context
'when build is cancelable'
do
context
'when build is cancelable'
do
before
do
before
do
build
.
update
(
status: :running
)
job
.
update
(
status: :running
)
end
end
it
'contains cancel path'
do
it
'contains cancel path'
do
...
@@ -59,7 +59,7 @@ describe BuildEntity do
...
@@ -59,7 +59,7 @@ describe BuildEntity do
end
end
end
end
context
'when
build is a regular build
'
do
context
'when
job is a regular job
'
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
...
@@ -69,8 +69,8 @@ describe BuildEntity do
...
@@ -69,8 +69,8 @@ describe BuildEntity do
end
end
end
end
context
'when
build
is a manual action'
do
context
'when
job
is a manual action'
do
let
(
:
build
)
{
create
(
:ci_build
,
:manual
)
}
let
(
:
job
)
{
create
(
:ci_build
,
:manual
)
}
context
'when user is allowed to trigger action'
do
context
'when user is allowed to trigger action'
do
before
do
before
do
...
@@ -99,4 +99,25 @@ describe BuildEntity do
...
@@ -99,4 +99,25 @@ describe BuildEntity do
end
end
end
end
end
end
context
'when job is generic commit status'
do
let
(
:job
)
{
create
(
:generic_commit_status
,
target_url:
'http://google.com'
)
}
it
'contains paths to target action'
do
expect
(
subject
).
to
include
(
:build_path
)
end
it
'does not contain paths to other action paths'
do
expect
(
subject
).
not_to
include
(
:retry_path
,
:cancel_path
,
:play_path
)
end
it
'contains timestamps'
do
expect
(
subject
).
to
include
(
:created_at
,
:updated_at
)
end
it
'contains details'
do
expect
(
subject
).
to
include
:status
expect
(
subject
[
:status
]).
to
include
:icon
,
:favicon
,
:text
,
:label
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