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
Boxiang Sun
gitlab-ce
Commits
137f74b5
Commit
137f74b5
authored
Oct 03, 2018
by
Shinya Maeda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add job_entity_spec
parent
66b3bd5e
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
1 deletion
+21
-1
app/serializers/job_entity.rb
app/serializers/job_entity.rb
+9
-1
spec/serializers/job_entity_spec.rb
spec/serializers/job_entity_spec.rb
+12
-0
No files found.
app/serializers/job_entity.rb
View file @
137f74b5
...
...
@@ -24,8 +24,12 @@ class JobEntity < Grape::Entity
path_to
(
:play_namespace_project_job
,
build
)
end
expose
:unschedule_path
,
if:
->
(
*
)
{
scheduled?
}
do
|
build
|
path_to
(
:unschedule_namespace_project_job
,
build
)
end
expose
:playable?
,
as: :playable
expose
:scheduled_at
expose
:scheduled_at
,
if:
->
(
*
)
{
scheduled?
}
expose
:created_at
expose
:updated_at
expose
:detailed_status
,
as: :status
,
with:
DetailedStatusEntity
...
...
@@ -48,6 +52,10 @@ class JobEntity < Grape::Entity
build
.
playable?
&&
can?
(
request
.
current_user
,
:update_build
,
build
)
end
def
scheduled?
build
.
scheduled?
end
def
detailed_status
build
.
detailed_status
(
request
.
current_user
)
end
...
...
spec/serializers/job_entity_spec.rb
View file @
137f74b5
...
...
@@ -109,6 +109,18 @@ describe JobEntity do
end
end
context
'when job is scheduled'
do
let
(
:job
)
{
create
(
:ci_build
,
:scheduled
)
}
it
'contains path to unschedule action'
do
expect
(
subject
).
to
include
(
:unschedule_path
)
end
it
'contains scheduled_at'
do
expect
(
subject
[
:scheduled_at
]).
to
eq
(
job
.
scheduled_at
)
end
end
context
'when job is generic commit status'
do
let
(
:job
)
{
create
(
:generic_commit_status
,
target_url:
'http://google.com'
)
}
...
...
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