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
34c1c8a3
Commit
34c1c8a3
authored
Aug 01, 2016
by
Z.J. van de Weg
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Minor fixes in the Env API endpoints
parent
1b72256f
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
24 additions
and
4 deletions
+24
-4
app/controllers/projects/environments_controller.rb
app/controllers/projects/environments_controller.rb
+1
-1
lib/api/environments.rb
lib/api/environments.rb
+5
-1
spec/requests/api/environments_spec.rb
spec/requests/api/environments_spec.rb
+18
-2
No files found.
app/controllers/projects/environments_controller.rb
View file @
34c1c8a3
...
@@ -2,7 +2,7 @@ class Projects::EnvironmentsController < Projects::ApplicationController
...
@@ -2,7 +2,7 @@ class Projects::EnvironmentsController < Projects::ApplicationController
layout
'project'
layout
'project'
before_action
:authorize_read_environment!
before_action
:authorize_read_environment!
before_action
:authorize_create_environment!
,
only:
[
:new
,
:create
]
before_action
:authorize_create_environment!
,
only:
[
:new
,
:create
]
before_action
:authorize_update_environment!
,
only:
[
:edit
,
:destroy
]
before_action
:authorize_update_environment!
,
only:
[
:edit
,
:
update
,
:
destroy
]
before_action
:environment
,
only:
[
:show
,
:edit
,
:update
,
:destroy
]
before_action
:environment
,
only:
[
:show
,
:edit
,
:update
,
:destroy
]
def
index
def
index
...
...
lib/api/environments.rb
View file @
34c1c8a3
...
@@ -11,6 +11,10 @@ module API
...
@@ -11,6 +11,10 @@ module API
detail
'This feature was introduced in GitLab 8.11.'
detail
'This feature was introduced in GitLab 8.11.'
success
Entities
::
Environment
success
Entities
::
Environment
end
end
params
do
optional
:page
,
type:
Integer
,
desc:
'Page number of the current request'
optional
:per_page
,
type:
Integer
,
desc:
'Number of items per page'
end
get
':id/environments'
do
get
':id/environments'
do
authorize!
:read_environment
,
user_project
authorize!
:read_environment
,
user_project
...
...
spec/requests/api/environments_spec.rb
View file @
34c1c8a3
...
@@ -14,6 +14,10 @@ describe API::API, api: true do
...
@@ -14,6 +14,10 @@ describe API::API, api: true do
describe
'GET /projects/:id/environments'
do
describe
'GET /projects/:id/environments'
do
context
'as member of the project'
do
context
'as member of the project'
do
it_behaves_like
'a paginated resources'
do
let
(
:request
)
{
get
api
(
"/projects/
#{
project
.
id
}
/environments"
,
user
)
}
end
it
'returns project environments'
do
it
'returns project environments'
do
get
api
(
"/projects/
#{
project
.
id
}
/environments"
,
user
)
get
api
(
"/projects/
#{
project
.
id
}
/environments"
,
user
)
...
@@ -59,9 +63,13 @@ describe API::API, api: true do
...
@@ -59,9 +63,13 @@ describe API::API, api: true do
context
'a non member'
do
context
'a non member'
do
it
'rejects the request'
do
it
'rejects the request'
do
post
api
(
"/projects/
#{
project
.
id
}
/environments"
,
non_member
)
post
api
(
"/projects/
#{
project
.
id
}
/environments"
,
non_member
)
,
name:
'gitlab.com'
expect
(
response
).
to
have_http_status
(
400
)
expect
(
response
).
to
have_http_status
(
404
)
end
it
'returns a 400 when the required params are missing'
do
post
api
(
"/projects/12345/environments"
,
non_member
),
external_url:
'http://env.git.com'
end
end
end
end
end
end
...
@@ -109,5 +117,13 @@ describe API::API, api: true do
...
@@ -109,5 +117,13 @@ describe API::API, api: true do
expect
(
json_response
[
'message'
]).
to
eq
(
'404 Not found'
)
expect
(
json_response
[
'message'
]).
to
eq
(
'404 Not found'
)
end
end
end
end
context
'a non member'
do
it
'rejects the request'
do
delete
api
(
"/projects/
#{
project
.
id
}
/environments/
#{
environment
.
id
}
"
,
non_member
)
expect
(
response
).
to
have_http_status
(
404
)
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