Commit 46082f4b authored by Lin Jen-Shin's avatar Lin Jen-Shin
Browse files
parent d4713e049890
......@@ -306,17 +306,12 @@ def check_repository_storages
end
def check_default_artifacts_expire_in
return true unless default_artifacts_expire_in
if ChronicDuration.parse(default_artifacts_expire_in).nil?
errors.add(:default_artifacts_expire_in,
if default_artifacts_expire_in &&
ChronicDuration.parse(default_artifacts_expire_in).nil?
errors.add(:default_artifacts_expiration,
"can't be 0. Leave it blank for no expiration")
false
else
true
end
rescue ChronicDuration::DurationParseError => e
errors.add(:default_artifacts_expire_in, ": #{e.message}")
false
errors.add(:default_artifacts_expiration, "is invalid")
end
end
......@@ -34,12 +34,16 @@
setting.update(default_artifacts_expire_in: 'a')
expect(setting).to be_invalid
expect(setting.errors.messages)
.to have_key(:default_artifacts_expiration)
end
it 'does not allow 0' do
setting.update(default_artifacts_expire_in: '0')
expect(setting).to be_invalid
expect(setting.errors.messages)
.to have_key(:default_artifacts_expiration)
end
it 'sets the value if it is valid' 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