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
d44653da
Commit
d44653da
authored
Jan 13, 2016
by
Tomasz Maczukin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add some fixes after review
parent
e0ec69d9
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
16 additions
and
19 deletions
+16
-19
trigger.rb
app/models/ci/trigger.rb
+4
-0
entities.rb
lib/api/entities.rb
+1
-7
triggers.rb
lib/api/triggers.rb
+5
-6
triggers_spec.rb
spec/requests/api/triggers_spec.rb
+6
-6
No files found.
app/models/ci/trigger.rb
View file @
d44653da
...
...
@@ -32,6 +32,10 @@ module Ci
trigger_requests
.
last
end
def
last_used
last_trigger_request
.
try
(
:created_at
)
end
def
short_token
token
[
0
...
10
]
end
...
...
lib/api/entities.rb
View file @
d44653da
...
...
@@ -367,13 +367,7 @@ module API
end
class
Trigger
<
Grape
::
Entity
expose
:token
,
:created_at
,
:updated_at
,
:deleted_at
expose
:last_used
do
|
repo_obj
,
_options
|
if
repo_obj
.
respond_to?
(
:last_trigger_request
)
request
=
repo_obj
.
last_trigger_request
request
.
created_at
if
request
end
end
expose
:token
,
:created_at
,
:updated_at
,
:deleted_at
,
:last_used
end
end
end
lib/api/triggers.rb
View file @
d44653da
...
...
@@ -73,10 +73,10 @@ module API
authenticate!
authorize_admin_project
trigger
s
=
user_project
.
triggers
.
where
(
token:
params
[
:token
]
)
return
not_found!
(
'Trigger'
)
if
triggers
.
empty?
trigger
=
user_project
.
triggers
.
find_by
(
token:
params
[
:token
].
to_s
)
return
not_found!
(
'Trigger'
)
unless
trigger
present
trigger
s
.
first
,
with:
Entities
::
Trigger
present
trigger
,
with:
Entities
::
Trigger
end
# Create trigger
...
...
@@ -89,8 +89,7 @@ module API
authenticate!
authorize_admin_project
trigger
=
user_project
.
triggers
.
new
trigger
.
save
trigger
=
user_project
.
triggers
.
create
present
trigger
,
with:
Entities
::
Trigger
end
...
...
@@ -106,7 +105,7 @@ module API
authenticate!
authorize_admin_project
trigger
=
user_project
.
triggers
.
where
(
token:
params
[
:token
]).
first
trigger
=
user_project
.
triggers
.
find_by
(
token:
params
[
:token
].
to_s
)
return
not_found!
(
'Trigger'
)
unless
trigger
trigger
.
destroy
...
...
spec/requests/api/triggers_spec.rb
View file @
d44653da
...
...
@@ -105,7 +105,7 @@ describe API::API do
end
end
context
'unauthenti
k
ated user'
do
context
'unauthenti
c
ated user'
do
it
'should not return triggers list'
do
get
api
(
"/projects/
#{
project
.
id
}
/triggers"
)
...
...
@@ -123,7 +123,7 @@ describe API::API do
expect
(
json_response
).
to
be_a
(
Hash
)
end
it
'should respond
e
with 404 Not Found if requesting non-existing trigger'
do
it
'should respond with 404 Not Found if requesting non-existing trigger'
do
get
api
(
"/projects/
#{
project
.
id
}
/triggers/abcdef012345"
,
user
)
expect
(
response
.
status
).
to
eq
(
404
)
...
...
@@ -138,7 +138,7 @@ describe API::API do
end
end
context
'unauthenti
k
ated user'
do
context
'unauthenti
c
ated user'
do
it
'should not return triggers list'
do
get
api
(
"/projects/
#{
project
.
id
}
/triggers/
#{
trigger
.
token
}
"
)
...
...
@@ -167,7 +167,7 @@ describe API::API do
end
end
context
'unauthenti
k
ated user'
do
context
'unauthenti
c
ated user'
do
it
'should not create trigger'
do
post
api
(
"/projects/
#{
project
.
id
}
/triggers"
)
...
...
@@ -185,7 +185,7 @@ describe API::API do
expect
(
response
.
status
).
to
eq
(
200
)
end
it
'should respond
e
with 404 Not Found if requesting non-existing trigger'
do
it
'should respond with 404 Not Found if requesting non-existing trigger'
do
delete
api
(
"/projects/
#{
project
.
id
}
/triggers/abcdef012345"
,
user
)
expect
(
response
.
status
).
to
eq
(
404
)
...
...
@@ -200,7 +200,7 @@ describe API::API do
end
end
context
'unauthenti
k
ated user'
do
context
'unauthenti
c
ated user'
do
it
'should not delete trigger'
do
delete
api
(
"/projects/
#{
project
.
id
}
/triggers/
#{
trigger
.
token
}
"
)
...
...
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