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
c43a82cd
Commit
c43a82cd
authored
Oct 31, 2017
by
Shinya Maeda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
specs for serializers.
parent
709b8b61
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
39 additions
and
18 deletions
+39
-18
spec/serializers/cluster_entity_spec.rb
spec/serializers/cluster_entity_spec.rb
+27
-11
spec/serializers/cluster_serializer_spec.rb
spec/serializers/cluster_serializer_spec.rb
+12
-7
No files found.
spec/serializers/cluster_entity_spec.rb
View file @
c43a82cd
require
'spec_helper'
describe
ClusterEntity
do
set
(
:cluster
)
{
create
(
:gcp_cluster
,
:errored
)
}
let
(
:request
)
{
double
(
'request'
)
}
describe
'#as_json'
do
subject
{
described_class
.
new
(
cluster
).
as_json
}
let
(
:entity
)
do
described_class
.
new
(
cluster
)
end
context
'when provider type is gcp'
do
let
(
:cluster
)
{
create
(
:cluster
,
provider_type: :gcp
,
provider_gcp:
provider
)
}
describe
'#as_json
'
do
subject
{
entity
.
as_json
}
context
'when status is creating
'
do
let
(
:provider
)
{
create
(
:provider_gcp
,
:creating
)
}
it
'contains status'
do
expect
(
subject
[
:status
]).
to
eq
(
:errored
)
it
'has corresponded data'
do
expect
(
subject
[
:status
]).
to
eq
(
:creating
)
expect
(
subject
[
:status_reason
]).
to
be_nil
end
end
context
'when status is errored'
do
let
(
:provider
)
{
create
(
:provider_gcp
,
:errored
)
}
it
'has corresponded data'
do
expect
(
subject
[
:status
]).
to
eq
(
:errored
)
expect
(
subject
[
:status_reason
]).
to
eq
(
provider
.
status_reason
)
end
end
end
it
'contains status reason'
do
expect
(
subject
[
:status_reason
]).
to
eq
(
'general error'
)
context
'when provider type is user'
do
let
(
:cluster
)
{
create
(
:cluster
,
provider_type: :user
)
}
it
'has nil'
do
expect
(
subject
[
:status
]).
to
be_nil
expect
(
subject
[
:status_reason
]).
to
be_nil
end
end
end
end
spec/serializers/cluster_serializer_spec.rb
View file @
c43a82cd
require
'spec_helper'
describe
ClusterSerializer
do
let
(
:serializer
)
do
described_class
.
new
end
describe
'#represent_status'
do
subject
{
serializer
.
represent_status
(
resource
)
}
subject
{
described_class
.
new
.
represent_status
(
cluster
)
}
context
'when provider type is gcp'
do
let
(
:cluster
)
{
create
(
:cluster
,
provider_type: :gcp
,
provider_gcp:
provider
)
}
let
(
:provider
)
{
create
(
:provider_gcp
,
:errored
)
}
it
'serializes only status'
do
expect
(
subject
.
keys
).
to
contain_exactly
(
:status
,
:status_reason
)
end
end
context
'when
represents only status
'
do
let
(
:
resource
)
{
create
(
:gcp_cluster
,
:errored
)
}
context
'when
provider type is user
'
do
let
(
:
cluster
)
{
create
(
:cluster
,
provider_type: :user
)
}
it
'serializes only status'
do
expect
(
subject
.
keys
).
to
contain_exactly
(
:status
,
:status_reason
)
...
...
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