Commit 2fcf80de authored by Fabio Pitino's avatar Fabio Pitino

Strip whitespace for PipelineSchedule#cron

parent acb55198
...@@ -5,6 +5,7 @@ module Ci ...@@ -5,6 +5,7 @@ module Ci
extend Gitlab::Ci::Model extend Gitlab::Ci::Model
include Importable include Importable
include IgnorableColumn include IgnorableColumn
include StripAttribute
ignore_column :deleted_at ignore_column :deleted_at
...@@ -22,6 +23,8 @@ module Ci ...@@ -22,6 +23,8 @@ module Ci
before_save :set_next_run_at before_save :set_next_run_at
strip_attributes :cron
scope :active, -> { where(active: true) } scope :active, -> { where(active: true) }
scope :inactive, -> { where(active: false) } scope :inactive, -> { where(active: false) }
......
...@@ -35,6 +35,15 @@ describe Ci::PipelineSchedule do ...@@ -35,6 +35,15 @@ describe Ci::PipelineSchedule do
expect(pipeline_schedule).not_to be_valid expect(pipeline_schedule).not_to be_valid
end end
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 end
describe '#set_next_run_at' do 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