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
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
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
49 additions
and
0 deletions
+49
-0
spec/serializers/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