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
0d014feb
Commit
0d014feb
authored
Dec 31, 2015
by
Tomasz Maczukin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add delete feature to variables API
parent
a692ce1c
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
40 additions
and
1 deletion
+40
-1
lib/api/variables.rb
lib/api/variables.rb
+12
-0
spec/requests/api/variables_spec.rb
spec/requests/api/variables_spec.rb
+28
-1
No files found.
lib/api/variables.rb
View file @
0d014feb
...
@@ -57,6 +57,18 @@ module API
...
@@ -57,6 +57,18 @@ module API
present
variable
,
with:
Entities
::
Variable
present
variable
,
with:
Entities
::
Variable
end
end
# Delete existing variable of a project
#
# Parameters:
# id (required) - The ID of a project
# variable_id (required) - The ID of a variable
# Exanoke Reqyest:
# DELETE /projects/:id/variables/:variable_id
delete
':id/variables/:variable_id'
do
variable
=
user_project
.
variables
.
where
(
id:
params
[
:variable_id
].
to_i
).
first
variable
.
destroy
end
end
end
end
end
end
end
spec/requests/api/variables_spec.rb
View file @
0d014feb
...
@@ -101,11 +101,38 @@ describe API::API, api: true do
...
@@ -101,11 +101,38 @@ describe API::API, api: true do
end
end
context
'unauthorized user'
do
context
'unauthorized user'
do
it
'should not
return project variable details
'
do
it
'should not
update variable
'
do
put
api
(
"/projects/
#{
project
.
id
}
/variables/
#{
variable
.
id
}
"
)
put
api
(
"/projects/
#{
project
.
id
}
/variables/
#{
variable
.
id
}
"
)
expect
(
response
.
status
).
to
eq
(
401
)
expect
(
response
.
status
).
to
eq
(
401
)
end
end
end
end
end
end
describe
'DELETE /projects/:id/variables/:variable_id'
do
context
'authorized user with proper permissions'
do
it
'should delete variable'
do
expect
do
delete
api
(
"/projects/
#{
project
.
id
}
/variables/
#{
variable
.
id
}
"
,
user
)
end
.
to
change
{
project
.
variables
.
count
}.
by
(
-
1
)
expect
(
response
.
status
).
to
eq
(
200
)
end
end
context
'authorized user with invalid permissions'
do
it
'should not delete variable'
do
delete
api
(
"/projects/
#{
project
.
id
}
/variables/
#{
variable
.
id
}
"
,
user2
)
expect
(
response
.
status
).
to
eq
(
403
)
end
end
context
'unauthorized user'
do
it
'should not delete variable'
do
delete
api
(
"/projects/
#{
project
.
id
}
/variables/
#{
variable
.
id
}
"
)
expect
(
response
.
status
).
to
eq
(
401
)
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