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
f0060743
Commit
f0060743
authored
Jan 05, 2016
by
Tomasz Maczukin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add delete feature to triggers API
parent
30985008
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
52 additions
and
0 deletions
+52
-0
lib/api/triggers.rb
lib/api/triggers.rb
+19
-0
spec/requests/api/triggers_spec.rb
spec/requests/api/triggers_spec.rb
+33
-0
No files found.
lib/api/triggers.rb
View file @
f0060743
...
@@ -61,6 +61,25 @@ module API
...
@@ -61,6 +61,25 @@ module API
present
triggers
,
with:
Entities
::
Trigger
present
triggers
,
with:
Entities
::
Trigger
end
end
# Delete trigger
#
# Parameters:
# id (required) - The ID of a project
# trigger_id - The ID of trigger to delete
# Example Request:
# DELETE /projects/:id/triggers/:trigger_id
delete
':id/triggers/:trigger_id'
do
authenticate!
authorize_admin_project
trigger
=
user_project
.
triggers
.
where
(
id:
params
[
:trigger_id
].
to_i
).
first
return
not_found!
(
'Trigger'
)
unless
trigger
trigger
.
destroy
present
trigger
,
with:
Entities
::
Trigger
end
end
end
end
end
end
end
spec/requests/api/triggers_spec.rb
View file @
f0060743
...
@@ -114,4 +114,37 @@ describe API::API do
...
@@ -114,4 +114,37 @@ describe API::API do
end
end
end
end
end
end
describe
'DELETE /projects/:id/triggets/:trigger_id'
do
context
'authenticated user with valid permissions'
do
it
'should delete trigger'
do
expect
do
delete
api
(
"/projects/
#{
project
.
id
}
/triggers/
#{
trigger
.
id
}
"
,
user
)
end
.
to
change
{
project
.
triggers
.
count
}.
by
(
-
1
)
expect
(
response
.
status
).
to
eq
(
200
)
end
it
'should responde with 404 Not Found if requesting non-existing trigger'
do
delete
api
(
"/projects/
#{
project
.
id
}
/triggers/9999"
,
user
)
expect
(
response
.
status
).
to
eq
(
404
)
end
end
context
'authenticated user with invalid permissions'
do
it
'should not delete trigger'
do
delete
api
(
"/projects/
#{
project
.
id
}
/triggers/
#{
trigger
.
id
}
"
,
user2
)
expect
(
response
.
status
).
to
eq
(
403
)
end
end
context
'unauthentikated user'
do
it
'should not delete trigger'
do
delete
api
(
"/projects/
#{
project
.
id
}
/triggers/
#{
trigger
.
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