Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorShinya Maeda <gitlab.shinyamaeda@gmail.com>2017-05-12 20:10:14 +0300
committerShinya Maeda <gitlab.shinyamaeda@gmail.com>2017-05-30 17:55:08 +0300
commitfbb070646aeccab5e46f300d130c20fa5a0a22fa (patch)
treead817749f9fdf6936896f2d9a3a87273cc7eb9fd /spec
parent0a11ab48993d092bd730af9b378fbf665b255625 (diff)
Add validation spec
Diffstat (limited to 'spec')
-rw-r--r--spec/requests/api/pipeline_schedules_spec.rb32
1 files changed, 21 insertions, 11 deletions
diff --git a/spec/requests/api/pipeline_schedules_spec.rb b/spec/requests/api/pipeline_schedules_spec.rb
index 6a3cc89909d..bf61c9de14d 100644
--- a/spec/requests/api/pipeline_schedules_spec.rb
+++ b/spec/requests/api/pipeline_schedules_spec.rb
@@ -118,6 +118,17 @@ describe API::PipelineSchedules do
expect(response).to have_http_status(:bad_request)
end
end
+
+ context 'when cron has validation error' do
+ it 'does not create pipeline_schedule' do
+ post api("/projects/#{project.id}/pipeline_schedules", developer),
+ description: description, ref: ref, cron: 'invalid-cron',
+ cron_timezone: cron_timezone, active: active
+
+ expect(response).to have_http_status(:bad_request)
+ expect(json_response['message']).to have_key('cron')
+ end
+ end
end
context 'authenticated user with invalid permissions' do
@@ -147,17 +158,6 @@ describe API::PipelineSchedules do
end
context 'authenticated user with valid permissions' do
- let(:new_ref) { 'patch-x' }
-
- it 'updates ref' do
- put api("/projects/#{project.id}/pipeline_schedules/#{pipeline_schedule.id}", developer),
- ref: new_ref
-
- expect(response).to have_http_status(:ok)
- expect(response).to match_response_schema('pipeline_schedule')
- expect(json_response['ref']).to eq(new_ref)
- end
-
let(:new_cron) { '1 2 3 4 *' }
it 'updates cron' do
@@ -173,6 +173,16 @@ describe API::PipelineSchedules do
expect(pipeline_schedule.next_run_at.day).to eq(3)
expect(pipeline_schedule.next_run_at.month).to eq(4)
end
+
+ context 'when cron has validation error' do
+ it 'does not update pipeline_schedule' do
+ put api("/projects/#{project.id}/pipeline_schedules/#{pipeline_schedule.id}", developer),
+ cron: 'invalid-cron'
+
+ expect(response).to have_http_status(:bad_request)
+ expect(json_response['message']).to have_key('cron')
+ end
+ end
end
context 'authenticated user with invalid permissions' do