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
63ca126e
Commit
63ca126e
authored
May 27, 2017
by
Shinya Maeda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve API with optinal and default. Allow to use scope as a parameter.
parent
b17c8d67
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
25 additions
and
3 deletions
+25
-3
lib/api/pipeline_schedules.rb
lib/api/pipeline_schedules.rb
+7
-3
spec/requests/api/pipeline_schedules_spec.rb
spec/requests/api/pipeline_schedules_spec.rb
+18
-0
No files found.
lib/api/pipeline_schedules.rb
View file @
63ca126e
...
...
@@ -13,11 +13,15 @@ module API
end
params
do
use
:pagination
optional
:scope
,
type:
String
,
values:
%w[active inactive]
,
desc:
'The scope of pipeline schedules'
end
get
':id/pipeline_schedules'
do
authorize!
:read_pipeline_schedule
,
user_project
present
paginate
(
pipeline_schedules
),
with:
Entities
::
PipelineSchedule
schedules
=
PipelineSchedulesFinder
.
new
(
user_project
).
execute
(
scope:
params
[
:scope
])
.
preload
([
:owner
,
:last_pipeline
])
present
paginate
(
schedules
),
with:
Entities
::
PipelineSchedule
end
desc
'Get a single pipeline schedule'
do
...
...
@@ -41,8 +45,8 @@ module API
requires
:description
,
type:
String
,
desc:
'The description of pipeline schedule'
requires
:ref
,
type:
String
,
desc:
'The branch/tag name will be triggered'
requires
:cron
,
type:
String
,
desc:
'The cron'
requires
:cron_timezone
,
type:
String
,
desc:
'The timezone'
requires
:active
,
type:
Boolean
,
desc:
'The activation of pipeline schedule'
optional
:cron_timezone
,
type:
String
,
default:
'UTC'
,
desc:
'The timezone'
optional
:active
,
type:
Boolean
,
default:
true
,
desc:
'The activation of pipeline schedule'
end
post
':id/pipeline_schedules'
do
authorize!
:create_pipeline_schedule
,
user_project
...
...
spec/requests/api/pipeline_schedules_spec.rb
View file @
63ca126e
...
...
@@ -43,6 +43,24 @@ describe API::PipelineSchedules do
get
api
(
"/projects/
#{
project
.
id
}
/pipeline_schedules"
,
developer
)
end
.
not_to
exceed_query_limit
(
control_count
)
end
%w[active inactive]
.
each
do
|
target
|
context
"when scope is
#{
target
}
"
do
before
do
create
(
:ci_pipeline_schedule
,
project:
project
,
active:
active?
(
target
))
end
it
'returns matched pipeline schedules'
do
get
api
(
"/projects/
#{
project
.
id
}
/pipeline_schedules"
,
developer
),
scope:
target
expect
(
json_response
.
map
{
|
r
|
r
[
'active'
]
}).
to
all
(
eq
(
active?
(
target
)))
end
end
def
active?
(
str
)
(
str
==
'active'
)
?
true
:
false
end
end
end
context
'authenticated user with invalid permissions'
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