BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
2150d98a
Commit
2150d98a
authored
Feb 03, 2017
by
Grzegorz Bizon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add specs for environments serializer pagination
parent
888fba1e
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
49 additions
and
0 deletions
+49
-0
environment_serializer_spec.rb
spec/serializers/environment_serializer_spec.rb
+49
-0
No files found.
spec/serializers/environment_serializer_spec.rb
View file @
2150d98a
...
@@ -52,4 +52,53 @@ describe EnvironmentSerializer do
...
@@ -52,4 +52,53 @@ describe EnvironmentSerializer do
expect
(
json
).
to
be_an_instance_of
Array
expect
(
json
).
to
be_an_instance_of
Array
end
end
end
end
context
'when used with pagination'
do
let
(
:request
)
{
spy
(
'request'
)
}
let
(
:response
)
{
spy
(
'response'
)
}
let
(
:resource
)
{
Environment
.
all
}
let
(
:pagination
)
{
{
page:
1
,
per_page:
2
}
}
let
(
:serializer
)
do
described_class
.
new
(
project:
project
)
.
with_pagination
(
request
,
response
)
end
before
do
allow
(
request
).
to
receive
(
:query_parameters
)
.
and_return
(
pagination
)
end
subject
{
serializer
.
represent
(
resource
)
}
it
'creates a paginated serializer'
do
expect
(
serializer
).
to
be_paginated
end
context
'when resource is paginatable relation'
do
context
'when there is a single environment object in relation'
do
before
{
create
(
:environment
)
}
it
'serializes environments'
do
expect
(
subject
.
first
).
to
have_key
:id
end
end
context
'when multiple environment objects are serialized'
do
before
{
create_list
(
:environment
,
3
)
}
it
'serializes appropriate number of objects'
do
expect
(
subject
.
count
).
to
be
2
end
it
'appends relevant headers'
do
expect
(
response
).
to
receive
(
:[]=
).
with
(
'X-Total'
,
'3'
)
expect
(
response
).
to
receive
(
:[]=
).
with
(
'X-Total-Pages'
,
'2'
)
expect
(
response
).
to
receive
(
:[]=
).
with
(
'X-Per-Page'
,
'2'
)
subject
end
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