Commit 7a83c9e5 authored by Shinya Maeda's avatar Shinya Maeda

Merge branch 'master' into 'master'

Use the same duration limit in job and in rule

See merge request gitlab-org/gitlab!81411
parents a3f60806 7f392ed0
......@@ -24,7 +24,7 @@ module Gitlab
validates :config, allowed_keys: ALLOWED_KEYS
validates :config, disallowed_keys: %i[start_in], unless: :specifies_delay?
validates :start_in, presence: true, if: :specifies_delay?
validates :start_in, duration: { limit: '1 day' }, if: :specifies_delay?
validates :start_in, duration: { limit: '1 week' }, if: :specifies_delay?
with_options allow_nil: true do
validates :if, expression: true
......
......@@ -174,13 +174,13 @@ RSpec.describe Gitlab::Ci::Config::Entry::Rules::Rule do
end
context 'specifying a delayed job' do
let(:config) { { if: '$THIS || $THAT', when: 'delayed', start_in: '15 minutes' } }
let(:config) { { if: '$THIS || $THAT', when: 'delayed', start_in: '2 days' } }
it { is_expected.to be_valid }
it 'sets attributes for the job delay' do
expect(entry.when).to eq('delayed')
expect(entry.start_in).to eq('15 minutes')
expect(entry.start_in).to eq('2 days')
end
context 'without a when: key' do
......@@ -198,10 +198,20 @@ RSpec.describe Gitlab::Ci::Config::Entry::Rules::Rule do
it { is_expected.not_to be_valid }
it 'returns an error about tstart_in being blank' do
it 'returns an error about start_in being blank' do
expect(entry.errors).to include(/start in can't be blank/)
end
end
context 'when start_in value is longer than a week' do
let(:config) { { if: '$THIS || $THAT', when: 'delayed', start_in: '2 weeks' } }
it { is_expected.not_to be_valid }
it 'returns an error about start_in exceeding the limit' do
expect(entry.errors).to include(/start in should not exceed the limit/)
end
end
end
context 'when specifying unknown policy' 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