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
49c8bf4e
Commit
49c8bf4e
authored
Jan 05, 2016
by
Tomasz Maczukin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add create feature to triggers API
parent
f0060743
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
45 additions
and
0 deletions
+45
-0
triggers.rb
lib/api/triggers.rb
+16
-0
triggers_spec.rb
spec/requests/api/triggers_spec.rb
+29
-0
No files found.
lib/api/triggers.rb
View file @
49c8bf4e
...
...
@@ -62,6 +62,22 @@ module API
present
triggers
,
with:
Entities
::
Trigger
end
# Create trigger
#
# Parameters:
# id (required) - The ID of a project
# Example Request:
# POST /projects/:id/triggers
post
':id/triggers'
do
authenticate!
authorize_admin_project
trigger
=
user_project
.
triggers
.
new
trigger
.
save
present
trigger
,
with:
Entities
::
Trigger
end
# Delete trigger
#
# Parameters:
...
...
spec/requests/api/triggers_spec.rb
View file @
49c8bf4e
...
...
@@ -115,6 +115,35 @@ describe API::API do
end
end
describe
'POST /projects/:id/triggets'
do
context
'authenticated user with valid permissions'
do
it
'should create trigger'
do
expect
do
post
api
(
"/projects/
#{
project
.
id
}
/triggers"
,
user
)
end
.
to
change
{
project
.
triggers
.
count
}.
by
(
1
)
expect
(
response
.
status
).
to
eq
(
201
)
expect
(
json_response
).
to
be_a
(
Hash
)
end
end
context
'authenticated user with invalid permissions'
do
it
'should not create trigger'
do
post
api
(
"/projects/
#{
project
.
id
}
/triggers"
,
user2
)
expect
(
response
.
status
).
to
eq
(
403
)
end
end
context
'unauthentikated user'
do
it
'should not create trigger'
do
post
api
(
"/projects/
#{
project
.
id
}
/triggers"
)
expect
(
response
.
status
).
to
eq
(
401
)
end
end
end
describe
'DELETE /projects/:id/triggets/:trigger_id'
do
context
'authenticated user with valid permissions'
do
it
'should delete trigger'
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