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
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
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
9 deletions
+21
-9
environments_controller.rb
app/controllers/projects/environments_controller.rb
+3
-1
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
format
.
html
format
.
json
do
render
json:
EnvironmentSerializer
.
new
(
project:
@project
,
user:
current_user
)
.
new
(
project:
@project
,
user:
@current_user
)
.
with_pagination
(
request
,
response
)
.
within_folders
.
represent
(
@environments
)
end
end
...
...
spec/controllers/projects/environments_controller_spec.rb
View file @
efa05023
...
...
@@ -3,9 +3,13 @@ require 'spec_helper'
describe
Projects
::
EnvironmentsController
do
include
ApiHelpers
let
(
:environment
)
{
create
(
:environment
)
}
let
(
:project
)
{
environment
.
project
}
let
(
:user
)
{
create
(
:user
)
}
let
(
:user
)
{
create
(
:user
)
}
let
(
:project
)
{
create
(
:empty_project
)
}
let
(
:environment
)
do
create
(
:environment
,
name:
'production'
,
project:
project
)
end
before
do
project
.
team
<<
[
user
,
:master
]
...
...
@@ -22,14 +26,20 @@ describe Projects::EnvironmentsController do
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
get
:index
,
environment_params
(
format: :json
)
first_environment
=
json_response
.
first
expect
(
first_environment
).
not_to
be_empty
expect
(
first_environment
[
'name'
]).
to
eq
environment
.
name
expect
(
json_response
.
count
).
to
eq
2
expect
(
json_response
.
first
[
'name'
]).
to
eq
'production'
expect
(
json_response
.
second
[
'name'
]).
to
eq
'staging'
expect
(
json_response
.
second
[
'size'
]).
to
eq
2
expect
(
json_response
.
second
[
'latest'
][
'name'
]).
to
eq
'staging/review-2'
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