summaryrefslogtreecommitdiff
path: root/app/models/application_setting.rb
diff options
context:
space:
mode:
Diffstat (limited to 'app/models/application_setting.rb')
-rw-r--r--app/models/application_setting.rb12
1 files changed, 9 insertions, 3 deletions
diff --git a/app/models/application_setting.rb b/app/models/application_setting.rb
index 17193036fb6..19af40eacb4 100644
--- a/app/models/application_setting.rb
+++ b/app/models/application_setting.rb
@@ -306,9 +306,15 @@ class ApplicationSetting < ActiveRecord::Base
end
def check_default_artifacts_expire_in
- ChronicDuration.parse(default_artifacts_expire_in) if
- default_artifacts_expire_in
- true
+ return true unless default_artifacts_expire_in
+
+ if ChronicDuration.parse(default_artifacts_expire_in).nil?
+ errors.add(:default_artifacts_expire_in,
+ "can't be 0. Leave it blank for unlimited")
+ false
+ else
+ true
+ end
rescue ChronicDuration::DurationParseError => e
errors.add(:default_artifacts_expire_in, ": #{e.message}")
false