Commit cfd839d6 authored by Lin Jen-Shin's avatar Lin Jen-Shin

Fix tests and disallow 0 to make it consistent with .gitlab-ci.yml

parent 602f3b84
......@@ -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
......
......@@ -559,6 +559,7 @@ module API
expose :default_project_visibility
expose :default_snippet_visibility
expose :default_group_visibility
expose :default_artifacts_expire_in
expose :domain_whitelist
expose :domain_blacklist_enabled
expose :domain_blacklist
......
......@@ -57,7 +57,7 @@ module API
requires :shared_runners_text, type: String, desc: 'Shared runners text '
end
optional :max_artifacts_size, type: Integer, desc: "Set the maximum file size for each job's artifacts"
optional :default_artifacts_expire_in, type: Integer, desc: "Set the default expiration time for each job's artifacts"
optional :default_artifacts_expire_in, type: String, desc: "Set the default expiration time for each job's artifacts"
optional :max_pages_size, type: Integer, desc: 'Maximum size of pages in MB'
optional :container_registry_token_expire_delay, type: Integer, desc: 'Authorization token duration (minutes)'
optional :metrics_enabled, type: Boolean, desc: 'Enable the InfluxDB metrics'
......
......@@ -36,6 +36,12 @@ describe ApplicationSetting, models: true do
expect(setting).to be_invalid
end
it 'does not allow 0' do
setting.update(default_artifacts_expire_in: '0')
expect(setting).to be_invalid
end
it 'sets the value if it is valid' do
setting.update(default_artifacts_expire_in: '30 days')
......
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