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
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
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
40 additions
and
1 deletion
+40
-1
variables.rb
lib/api/variables.rb
+12
-0
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
present
variable
,
with:
Entities
::
Variable
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
spec/requests/api/variables_spec.rb
View file @
0d014feb
...
...
@@ -101,11 +101,38 @@ describe API::API, api: true do
end
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
}
"
)
expect
(
response
.
status
).
to
eq
(
401
)
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
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