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
61729204
Commit
61729204
authored
Mar 07, 2017
by
Shinya Maeda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add spec for entity and serializer
parent
01914554
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
53 additions
and
3 deletions
+53
-3
spec/serializers/build_entity_spec.rb
spec/serializers/build_entity_spec.rb
+12
-1
spec/serializers/build_serializer_spec.rb
spec/serializers/build_serializer_spec.rb
+26
-0
spec/serializers/pipeline_entity_spec.rb
spec/serializers/pipeline_entity_spec.rb
+1
-1
spec/serializers/pipeline_serializer_spec.rb
spec/serializers/pipeline_serializer_spec.rb
+13
-0
spec/serializers/status_entity_spec.rb
spec/serializers/status_entity_spec.rb
+1
-1
No files found.
spec/serializers/build_entity_spec.rb
View file @
61729204
require
'spec_helper'
require
'spec_helper'
describe
BuildEntity
do
describe
BuildEntity
do
let
(
:user
)
{
create
(
:user
)
}
let
(
:build
)
{
create
(
:ci_build
)
}
let
(
:build
)
{
create
(
:ci_build
)
}
let
(
:request
)
{
double
(
'request'
)
}
before
do
allow
(
request
).
to
receive
(
:user
).
and_return
(
user
)
end
let
(
:entity
)
do
let
(
:entity
)
do
described_class
.
new
(
build
,
request:
double
)
described_class
.
new
(
build
,
request:
request
)
end
end
subject
{
entity
.
as_json
}
subject
{
entity
.
as_json
}
...
@@ -22,6 +28,11 @@ describe BuildEntity do
...
@@ -22,6 +28,11 @@ describe BuildEntity do
expect
(
subject
).
to
include
(
:created_at
,
:updated_at
)
expect
(
subject
).
to
include
(
:created_at
,
:updated_at
)
end
end
it
'contains details'
do
expect
(
subject
).
to
include
:details
expect
(
subject
[
:details
][
:status
]).
to
include
:icon
,
:favicon
,
:text
,
:label
end
context
'when build is a regular job'
do
context
'when build 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
)
...
...
spec/serializers/build_serializer_spec.rb
0 → 100644
View file @
61729204
require
'spec_helper'
describe
BuildSerializer
do
let
(
:user
)
{
create
(
:user
)
}
let
(
:serializer
)
do
described_class
.
new
(
user:
user
)
end
subject
{
serializer
.
represent
(
resource
)
}
describe
'#represent'
do
context
'when used with status'
do
let
(
:serializer
)
do
described_class
.
new
(
user:
user
)
.
with_status
end
let
(
:resource
)
{
create
(
:ci_build
)
}
it
'serializes only status'
do
expect
(
subject
[
:details
][
:status
]).
not_to
be_empty
expect
(
subject
[
:details
].
keys
.
count
).
to
eq
1
end
end
end
end
spec/serializers/pipeline_entity_spec.rb
View file @
61729204
...
@@ -30,7 +30,7 @@ describe PipelineEntity do
...
@@ -30,7 +30,7 @@ describe PipelineEntity do
.
to
include
:duration
,
:finished_at
.
to
include
:duration
,
:finished_at
expect
(
subject
[
:details
])
expect
(
subject
[
:details
])
.
to
include
:stages
,
:artifacts
,
:manual_actions
.
to
include
:stages
,
:artifacts
,
:manual_actions
expect
(
subject
[
:details
][
:status
]).
to
include
:icon
,
:text
,
:label
expect
(
subject
[
:details
][
:status
]).
to
include
:icon
,
:
favicon
,
:
text
,
:label
end
end
it
'contains flags'
do
it
'contains flags'
do
...
...
spec/serializers/pipeline_serializer_spec.rb
View file @
61729204
...
@@ -93,5 +93,18 @@ describe PipelineSerializer do
...
@@ -93,5 +93,18 @@ describe PipelineSerializer do
end
end
end
end
end
end
context
'when used with status'
do
let
(
:serializer
)
do
described_class
.
new
(
user:
user
)
.
with_status
end
let
(
:resource
)
{
create
(
:ci_empty_pipeline
)
}
it
'serializes only status'
do
expect
(
subject
[
:details
][
:status
]).
not_to
be_empty
expect
(
subject
[
:details
].
keys
.
count
).
to
eq
1
end
end
end
end
end
end
spec/serializers/status_entity_spec.rb
View file @
61729204
...
@@ -16,7 +16,7 @@ describe StatusEntity do
...
@@ -16,7 +16,7 @@ describe StatusEntity do
subject
{
entity
.
as_json
}
subject
{
entity
.
as_json
}
it
'contains status details'
do
it
'contains status details'
do
expect
(
subject
).
to
include
:text
,
:icon
,
:label
,
:group
expect
(
subject
).
to
include
:text
,
:icon
,
:
favicon
,
:
label
,
:group
expect
(
subject
).
to
include
:has_details
,
:details_path
expect
(
subject
).
to
include
:has_details
,
:details_path
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