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
Jérome Perrin
gitlab-ce
Commits
c5177dd5
Commit
c5177dd5
authored
Dec 31, 2015
by
Tomasz Maczukin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add missing 'not_found' checks in variables API
parent
0d014feb
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
25 additions
and
0 deletions
+25
-0
lib/api/variables.rb
lib/api/variables.rb
+7
-0
spec/requests/api/variables_spec.rb
spec/requests/api/variables_spec.rb
+18
-0
No files found.
lib/api/variables.rb
View file @
c5177dd5
...
@@ -36,6 +36,8 @@ module API
...
@@ -36,6 +36,8 @@ module API
variables
.
where
(
key:
variable_id
)
variables
.
where
(
key:
variable_id
)
end
end
return
not_found!
(
'Variable'
)
if
variables
.
empty?
present
variables
.
first
,
with:
Entities
::
Variable
present
variables
.
first
,
with:
Entities
::
Variable
end
end
...
@@ -51,6 +53,8 @@ module API
...
@@ -51,6 +53,8 @@ module API
put
':id/variables/:variable_id'
do
put
':id/variables/:variable_id'
do
variable
=
user_project
.
variables
.
where
(
id:
params
[
:variable_id
].
to_i
).
first
variable
=
user_project
.
variables
.
where
(
id:
params
[
:variable_id
].
to_i
).
first
return
not_found!
(
'Variable'
)
unless
variable
variable
.
key
=
params
[
:key
]
variable
.
key
=
params
[
:key
]
variable
.
value
=
params
[
:value
]
variable
.
value
=
params
[
:value
]
variable
.
save!
variable
.
save!
...
@@ -67,6 +71,9 @@ module API
...
@@ -67,6 +71,9 @@ module API
# DELETE /projects/:id/variables/:variable_id
# DELETE /projects/:id/variables/:variable_id
delete
':id/variables/:variable_id'
do
delete
':id/variables/:variable_id'
do
variable
=
user_project
.
variables
.
where
(
id:
params
[
:variable_id
].
to_i
).
first
variable
=
user_project
.
variables
.
where
(
id:
params
[
:variable_id
].
to_i
).
first
return
not_found!
(
'Variable'
)
unless
variable
variable
.
destroy
variable
.
destroy
end
end
end
end
...
...
spec/requests/api/variables_spec.rb
View file @
c5177dd5
...
@@ -54,6 +54,12 @@ describe API::API, api: true do
...
@@ -54,6 +54,12 @@ describe API::API, api: true do
expect
(
json_response
[
'id'
]).
to
eq
(
variable
.
id
)
expect
(
json_response
[
'id'
]).
to
eq
(
variable
.
id
)
expect
(
json_response
[
'value'
]).
to
eq
(
variable
.
value
)
expect
(
json_response
[
'value'
]).
to
eq
(
variable
.
value
)
end
end
it
'should responde with 404 Not Found if requesting non-existing variable'
do
get
api
(
"/projects/
#{
project
.
id
}
/variables/9999"
,
user
)
expect
(
response
.
status
).
to
eq
(
404
)
end
end
end
context
'authorized user with invalid permissions'
do
context
'authorized user with invalid permissions'
do
...
@@ -90,6 +96,12 @@ describe API::API, api: true do
...
@@ -90,6 +96,12 @@ describe API::API, api: true do
expect
(
updated_variable
.
key
).
to
eq
(
'TEST_VARIABLE_1_UP'
)
expect
(
updated_variable
.
key
).
to
eq
(
'TEST_VARIABLE_1_UP'
)
expect
(
updated_variable
.
value
).
to
eq
(
'VALUE_1_UP'
)
expect
(
updated_variable
.
value
).
to
eq
(
'VALUE_1_UP'
)
end
end
it
'should responde with 404 Not Found if requesting non-existing variable'
do
put
api
(
"/projects/
#{
project
.
id
}
/variables/9999"
,
user
)
expect
(
response
.
status
).
to
eq
(
404
)
end
end
end
context
'authorized user with invalid permissions'
do
context
'authorized user with invalid permissions'
do
...
@@ -117,6 +129,12 @@ describe API::API, api: true do
...
@@ -117,6 +129,12 @@ describe API::API, api: true do
end
.
to
change
{
project
.
variables
.
count
}.
by
(
-
1
)
end
.
to
change
{
project
.
variables
.
count
}.
by
(
-
1
)
expect
(
response
.
status
).
to
eq
(
200
)
expect
(
response
.
status
).
to
eq
(
200
)
end
end
it
'should responde with 404 Not Found if requesting non-existing variable'
do
delete
api
(
"/projects/
#{
project
.
id
}
/variables/9999"
,
user
)
expect
(
response
.
status
).
to
eq
(
404
)
end
end
end
context
'authorized user with invalid permissions'
do
context
'authorized user with invalid permissions'
do
...
...
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