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
9185241a
Commit
9185241a
authored
May 13, 2017
by
Shinya Maeda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use attributes_for
parent
f8cb5fd6
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
24 deletions
+16
-24
spec/requests/api/pipeline_schedules_spec.rb
spec/requests/api/pipeline_schedules_spec.rb
+16
-24
No files found.
spec/requests/api/pipeline_schedules_spec.rb
View file @
9185241a
...
@@ -85,29 +85,28 @@ describe API::PipelineSchedules do
...
@@ -85,29 +85,28 @@ describe API::PipelineSchedules do
end
end
describe
'POST /projects/:id/pipeline_schedules'
do
describe
'POST /projects/:id/pipeline_schedules'
do
let
(
:
description
)
{
'pipeline_schedule'
}
let
(
:
params
)
do
let
(
:ref
)
{
'master'
}
attributes_for
(
:ci_pipeline_schedule
,
let
(
:cron
)
{
'* * * * *'
}
description:
'description'
,
ref:
'master'
,
cron:
'* * * * *'
,
let
(
:cron_timezone
)
{
'UTC'
}
cron_timezone:
'UTC'
,
active:
true
)
let
(
:active
)
{
true
}
end
context
'authenticated user with valid permissions'
do
context
'authenticated user with valid permissions'
do
context
'with required parameters'
do
context
'with required parameters'
do
it
'creates pipeline_schedule'
do
it
'creates pipeline_schedule'
do
expect
do
expect
do
post
api
(
"/projects/
#{
project
.
id
}
/pipeline_schedules"
,
developer
),
post
api
(
"/projects/
#{
project
.
id
}
/pipeline_schedules"
,
developer
),
description:
description
,
ref:
ref
,
cron:
cron
,
params
cron_timezone:
cron_timezone
,
active:
active
end
end
.
to
change
{
project
.
pipeline_schedules
.
count
}.
by
(
1
)
.
to
change
{
project
.
pipeline_schedules
.
count
}.
by
(
1
)
expect
(
response
).
to
have_http_status
(
:created
)
expect
(
response
).
to
have_http_status
(
:created
)
expect
(
response
).
to
match_response_schema
(
'pipeline_schedule'
)
expect
(
response
).
to
match_response_schema
(
'pipeline_schedule'
)
expect
(
json_response
[
'description'
]).
to
eq
(
description
)
expect
(
json_response
[
'description'
]).
to
eq
(
params
[
:description
]
)
expect
(
json_response
[
'ref'
]).
to
eq
(
ref
)
expect
(
json_response
[
'ref'
]).
to
eq
(
params
[
:ref
]
)
expect
(
json_response
[
'cron'
]).
to
eq
(
cron
)
expect
(
json_response
[
'cron'
]).
to
eq
(
params
[
:cron
]
)
expect
(
json_response
[
'cron_timezone'
]).
to
eq
(
cron_timezone
)
expect
(
json_response
[
'cron_timezone'
]).
to
eq
(
params
[
:cron_timezone
]
)
expect
(
json_response
[
'active'
]).
to
eq
(
active
)
expect
(
json_response
[
'active'
]).
to
eq
(
params
[
:active
]
)
end
end
end
end
...
@@ -122,8 +121,7 @@ describe API::PipelineSchedules do
...
@@ -122,8 +121,7 @@ describe API::PipelineSchedules do
context
'when cron has validation error'
do
context
'when cron has validation error'
do
it
'does not create pipeline_schedule'
do
it
'does not create pipeline_schedule'
do
post
api
(
"/projects/
#{
project
.
id
}
/pipeline_schedules"
,
developer
),
post
api
(
"/projects/
#{
project
.
id
}
/pipeline_schedules"
,
developer
),
description:
description
,
ref:
ref
,
cron:
'invalid-cron'
,
params
.
tap
{
|
_
|
params
[
'cron'
]
=
'invalid-cron'
}
cron_timezone:
cron_timezone
,
active:
active
expect
(
response
).
to
have_http_status
(
:bad_request
)
expect
(
response
).
to
have_http_status
(
:bad_request
)
expect
(
json_response
[
'message'
]).
to
have_key
(
'cron'
)
expect
(
json_response
[
'message'
]).
to
have_key
(
'cron'
)
...
@@ -133,9 +131,7 @@ describe API::PipelineSchedules do
...
@@ -133,9 +131,7 @@ describe API::PipelineSchedules do
context
'authenticated user with invalid permissions'
do
context
'authenticated user with invalid permissions'
do
it
'does not create pipeline_schedule'
do
it
'does not create pipeline_schedule'
do
post
api
(
"/projects/
#{
project
.
id
}
/pipeline_schedules"
,
user
),
post
api
(
"/projects/
#{
project
.
id
}
/pipeline_schedules"
,
user
),
params
description:
description
,
ref:
ref
,
cron:
cron
,
cron_timezone:
cron_timezone
,
active:
active
expect
(
response
).
to
have_http_status
(
:not_found
)
expect
(
response
).
to
have_http_status
(
:not_found
)
end
end
...
@@ -143,9 +139,7 @@ describe API::PipelineSchedules do
...
@@ -143,9 +139,7 @@ describe API::PipelineSchedules do
context
'unauthenticated user'
do
context
'unauthenticated user'
do
it
'does not create pipeline_schedule'
do
it
'does not create pipeline_schedule'
do
post
api
(
"/projects/
#{
project
.
id
}
/pipeline_schedules"
),
post
api
(
"/projects/
#{
project
.
id
}
/pipeline_schedules"
),
params
description:
description
,
ref:
ref
,
cron:
cron
,
cron_timezone:
cron_timezone
,
active:
active
expect
(
response
).
to
have_http_status
(
:unauthorized
)
expect
(
response
).
to
have_http_status
(
:unauthorized
)
end
end
...
@@ -158,16 +152,14 @@ describe API::PipelineSchedules do
...
@@ -158,16 +152,14 @@ describe API::PipelineSchedules do
end
end
context
'authenticated user with valid permissions'
do
context
'authenticated user with valid permissions'
do
let
(
:new_cron
)
{
'1 2 3 4 *'
}
it
'updates cron'
do
it
'updates cron'
do
put
api
(
"/projects/
#{
project
.
id
}
/pipeline_schedules/
#{
pipeline_schedule
.
id
}
"
,
developer
),
put
api
(
"/projects/
#{
project
.
id
}
/pipeline_schedules/
#{
pipeline_schedule
.
id
}
"
,
developer
),
cron:
new_cron
cron:
'1 2 3 4 *'
pipeline_schedule
.
reload
pipeline_schedule
.
reload
expect
(
response
).
to
have_http_status
(
:ok
)
expect
(
response
).
to
have_http_status
(
:ok
)
expect
(
response
).
to
match_response_schema
(
'pipeline_schedule'
)
expect
(
response
).
to
match_response_schema
(
'pipeline_schedule'
)
expect
(
json_response
[
'cron'
]).
to
eq
(
new_cron
)
expect
(
json_response
[
'cron'
]).
to
eq
(
'1 2 3 4 *'
)
expect
(
pipeline_schedule
.
next_run_at
.
min
).
to
eq
(
1
)
expect
(
pipeline_schedule
.
next_run_at
.
min
).
to
eq
(
1
)
expect
(
pipeline_schedule
.
next_run_at
.
hour
).
to
eq
(
2
)
expect
(
pipeline_schedule
.
next_run_at
.
hour
).
to
eq
(
2
)
expect
(
pipeline_schedule
.
next_run_at
.
day
).
to
eq
(
3
)
expect
(
pipeline_schedule
.
next_run_at
.
day
).
to
eq
(
3
)
...
...
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