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

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

parent 8ccc294ce4d3
......@@ -306,9 +306,15 @@ def check_repository_storages
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 @@ class ApplicationSetting < Grape::Entity
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 @@ def current_settings
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 @@
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