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
efa05023
Commit
efa05023
authored
Feb 03, 2017
by
Grzegorz Bizon
Committed by
Filipa Lacerda
Feb 09, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Enable grouping and pagination in environmnets API
parent
0fddece7
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
9 deletions
+21
-9
app/controllers/projects/environments_controller.rb
app/controllers/projects/environments_controller.rb
+3
-1
spec/controllers/projects/environments_controller_spec.rb
spec/controllers/projects/environments_controller_spec.rb
+18
-8
No files found.
app/controllers/projects/environments_controller.rb
View file @
efa05023
...
@@ -16,7 +16,9 @@ class Projects::EnvironmentsController < Projects::ApplicationController
...
@@ -16,7 +16,9 @@ class Projects::EnvironmentsController < Projects::ApplicationController
format
.
html
format
.
html
format
.
json
do
format
.
json
do
render
json:
EnvironmentSerializer
render
json:
EnvironmentSerializer
.
new
(
project:
@project
,
user:
current_user
)
.
new
(
project:
@project
,
user:
@current_user
)
.
with_pagination
(
request
,
response
)
.
within_folders
.
represent
(
@environments
)
.
represent
(
@environments
)
end
end
end
end
...
...
spec/controllers/projects/environments_controller_spec.rb
View file @
efa05023
...
@@ -3,9 +3,13 @@ require 'spec_helper'
...
@@ -3,9 +3,13 @@ require 'spec_helper'
describe
Projects
::
EnvironmentsController
do
describe
Projects
::
EnvironmentsController
do
include
ApiHelpers
include
ApiHelpers
let
(
:environment
)
{
create
(
:environment
)
}
let
(
:user
)
{
create
(
:user
)
}
let
(
:project
)
{
environment
.
project
}
let
(
:project
)
{
create
(
:empty_project
)
}
let
(
:user
)
{
create
(
:user
)
}
let
(
:environment
)
do
create
(
:environment
,
name:
'production'
,
project:
project
)
end
before
do
before
do
project
.
team
<<
[
user
,
:master
]
project
.
team
<<
[
user
,
:master
]
...
@@ -22,14 +26,20 @@ describe Projects::EnvironmentsController do
...
@@ -22,14 +26,20 @@ describe Projects::EnvironmentsController do
end
end
end
end
context
'when requesting JSON response'
do
context
'when requesting JSON response for folders'
do
before
do
create
(
:environment
,
project:
project
,
name:
'staging/review-1'
)
create
(
:environment
,
project:
project
,
name:
'staging/review-2'
)
end
it
'responds with correct JSON'
do
it
'responds with correct JSON'
do
get
:index
,
environment_params
(
format: :json
)
get
:index
,
environment_params
(
format: :json
)
first_environment
=
json_response
.
first
expect
(
json_response
.
count
).
to
eq
2
expect
(
json_response
.
first
[
'name'
]).
to
eq
'production'
expect
(
first_environment
).
not_to
be_empty
expect
(
json_response
.
second
[
'name'
]).
to
eq
'staging'
expect
(
first_environment
[
'name'
]).
to
eq
environment
.
name
expect
(
json_response
.
second
[
'size'
]).
to
eq
2
expect
(
json_response
.
second
[
'latest'
][
'name'
]).
to
eq
'staging/review-2'
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