Commit b3490d51 authored by Grzegorz Bizon's avatar Grzegorz Bizon

Merge branch 'strip-attr-cron-in-pipeline-schedule' into 'master'

Strip whitespace for PipelineSchedule#cron

See merge request gitlab-org/gitlab-ce!27990
parents 3371c1cb 2fcf80de
......@@ -5,6 +5,7 @@ module Ci
extend Gitlab::Ci::Model
include Importable
include IgnorableColumn
include StripAttribute
ignore_column :deleted_at
......@@ -22,6 +23,8 @@ module Ci
before_save :set_next_run_at
strip_attributes :cron
scope :active, -> { where(active: true) }
scope :inactive, -> { where(active: false) }
......
......@@ -35,6 +35,15 @@ describe Ci::PipelineSchedule do
expect(pipeline_schedule).not_to be_valid
end
end
context 'when cron contains trailing whitespaces' do
it 'strips the attribute' do
pipeline_schedule = build(:ci_pipeline_schedule, cron: ' 0 0 * * * ')
expect(pipeline_schedule).to be_valid
expect(pipeline_schedule.cron).to eq('0 0 * * *')
end
end
end
describe '#set_next_run_at' do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment