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
Tatuya Kamada
gitlab-ce
Commits
16a72896
Commit
16a72896
authored
Feb 03, 2017
by
Grzegorz Bizon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Extend environments folders and pagination API specs
parent
a5e5e4ac
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
84 additions
and
1 deletion
+84
-1
app/serializers/environment_serializer.rb
app/serializers/environment_serializer.rb
+1
-1
spec/serializers/environment_serializer_spec.rb
spec/serializers/environment_serializer_spec.rb
+83
-0
No files found.
app/serializers/environment_serializer.rb
View file @
16a72896
...
...
@@ -3,7 +3,7 @@ class EnvironmentSerializer < BaseSerializer
entity
EnvironmentEntity
def
with_folders
def
with
in
_folders
tap
{
@itemize
=
true
}
end
...
...
spec/serializers/environment_serializer_spec.rb
View file @
16a72896
...
...
@@ -53,6 +53,68 @@ describe EnvironmentSerializer do
end
end
context
'when representing environments within folders'
do
let
(
:serializer
)
do
described_class
.
new
(
project:
project
).
within_folders
end
let
(
:resource
)
{
Environment
.
all
}
subject
{
serializer
.
represent
(
resource
)
}
context
'when there is a single environment'
do
before
{
create
(
:environment
,
name:
'staging'
)
}
it
'represents one standalone environment'
do
expect
(
subject
.
count
).
to
eq
1
expect
(
subject
.
first
[
:name
]).
to
eq
'staging'
expect
(
subject
.
first
[
:size
]).
to
eq
1
expect
(
subject
.
first
[
:latest
][
:name
]).
to
eq
'staging'
end
end
context
'when there are multiple environments in folder'
do
before
do
create
(
:environment
,
name:
'staging/my-review-1'
)
create
(
:environment
,
name:
'staging/my-review-2'
)
end
it
'represents one item that is a folder'
do
expect
(
subject
.
count
).
to
eq
1
expect
(
subject
.
first
[
:name
]).
to
eq
'staging'
expect
(
subject
.
first
[
:size
]).
to
eq
2
expect
(
subject
.
first
[
:latest
][
:name
]).
to
eq
'staging/my-review-2'
expect
(
subject
.
first
[
:latest
][
:environment_type
]).
to
eq
'staging'
end
end
context
'when there are multiple folders and standalone environments'
do
before
do
create
(
:environment
,
name:
'staging/my-review-1'
)
create
(
:environment
,
name:
'staging/my-review-2'
)
create
(
:environment
,
name:
'production/my-review-3'
)
create
(
:environment
,
name:
'testing'
)
end
it
'represents multiple items grouped within folders'
do
expect
(
subject
.
count
).
to
eq
3
expect
(
subject
.
first
[
:name
]).
to
eq
'production'
expect
(
subject
.
first
[
:size
]).
to
eq
1
expect
(
subject
.
first
[
:latest
][
:name
]).
to
eq
'production/my-review-3'
expect
(
subject
.
first
[
:latest
][
:environment_type
]).
to
eq
'production'
expect
(
subject
.
second
[
:name
]).
to
eq
'staging'
expect
(
subject
.
second
[
:size
]).
to
eq
2
expect
(
subject
.
second
[
:latest
][
:name
]).
to
eq
'staging/my-review-2'
expect
(
subject
.
second
[
:latest
][
:environment_type
]).
to
eq
'staging'
expect
(
subject
.
third
[
:name
]).
to
eq
'testing'
expect
(
subject
.
third
[
:size
]).
to
eq
1
expect
(
subject
.
third
[
:latest
][
:name
]).
to
eq
'testing'
expect
(
subject
.
third
[
:latest
][
:environment_type
]).
to
be_nil
end
end
end
context
'when used with pagination'
do
let
(
:request
)
{
spy
(
'request'
)
}
let
(
:response
)
{
spy
(
'response'
)
}
...
...
@@ -99,6 +161,27 @@ describe EnvironmentSerializer do
subject
end
end
context
'when grouping environments within folders'
do
let
(
:serializer
)
do
described_class
.
new
(
project:
project
)
.
with_pagination
(
request
,
response
)
.
within_folders
end
before
do
create
(
:environment
,
name:
'staging/review-1'
)
create
(
:environment
,
name:
'staging/review-2'
)
create
(
:environment
,
name:
'production/deploy-3'
)
create
(
:environment
,
name:
'testing'
)
end
it
'paginates grouped items including ordering'
do
expect
(
subject
.
count
).
to
eq
2
expect
(
subject
.
first
[
:name
]).
to
eq
'production'
expect
(
subject
.
second
[
:name
]).
to
eq
'staging'
end
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