summaryrefslogtreecommitdiff
path: root/app/models/application_setting.rb
diff options
context:
space:
mode:
authorLin Jen-Shin <godfat@godfat.org>2017-02-21 02:25:35 +0800
committerLin Jen-Shin <godfat@godfat.org>2017-02-21 02:25:35 +0800
commit962f9efeb470afd0627f509621de4ff87124d656 (patch)
treeaa77a4129b3c644347450ddad4a496f314af73a2 /app/models/application_setting.rb
parenta538b0da9b34fb1b0f24607ff7dca2250ffdd4ea (diff)
downloadgitlab-ce-962f9efeb470afd0627f509621de4ff87124d656.tar.gz
Update error message and check with presence: true
Feedback: https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/9219#note_23762243 https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/9219#note_23762268
Diffstat (limited to 'app/models/application_setting.rb')
-rw-r--r--app/models/application_setting.rb17
1 files changed, 11 insertions, 6 deletions
diff --git a/app/models/application_setting.rb b/app/models/application_setting.rb
index 36832185b6f..b5ffc5f9ca9 100644
--- a/app/models/application_setting.rb
+++ b/app/models/application_setting.rb
@@ -80,6 +80,7 @@ class ApplicationSetting < ActiveRecord::Base
presence: true,
numericality: { only_integer: true, greater_than: 0 }
+ validates :default_artifacts_expire_in, presence: true
validate :check_default_artifacts_expire_in
validates :container_registry_token_expire_delay,
@@ -222,6 +223,14 @@ class ApplicationSetting < ActiveRecord::Base
create(defaults)
end
+ def self.human_attribute_name(attr, _options = {})
+ if attr == :default_artifacts_expire_in
+ 'Default artifacts expiration'
+ else
+ super
+ end
+ end
+
def home_page_url_column_exist
ActiveRecord::Base.connection.column_exists?(:application_settings, :home_page_url)
end
@@ -298,12 +307,8 @@ class ApplicationSetting < ActiveRecord::Base
end
def check_default_artifacts_expire_in
- if default_artifacts_expire_in.blank?
- errors.add(:default_artifacts_expiration, "is not presented")
- else
- ChronicDuration.parse(default_artifacts_expire_in)
- end
+ ChronicDuration.parse(default_artifacts_expire_in)
rescue ChronicDuration::DurationParseError
- errors.add(:default_artifacts_expiration, "is invalid")
+ errors.add(:default_artifacts_expiration, "is not a correct duration")
end
end