summaryrefslogtreecommitdiff
path: root/spec/models/application_setting_spec.rb
diff options
context:
space:
mode:
authorLin Jen-Shin <godfat@godfat.org>2017-02-16 23:40:13 +0800
committerLin Jen-Shin <godfat@godfat.org>2017-02-16 23:40:13 +0800
commiteede4ab1a2509ef4aa14d21527386224c4116adc (patch)
tree683b80180d6a53d77540f7f4d4344fb84b08f115 /spec/models/application_setting_spec.rb
parent37cc3aaefb65e775bd3baa93dd7dec218a76a23c (diff)
downloadgitlab-ce-eede4ab1a2509ef4aa14d21527386224c4116adc.tar.gz
0 for unlimited, disallow blank, feedback:
https://gitlab.com/gitlab-org/gitlab-ce/issues/27762#note_23520780
Diffstat (limited to 'spec/models/application_setting_spec.rb')
-rw-r--r--spec/models/application_setting_spec.rb26
1 files changed, 14 insertions, 12 deletions
diff --git a/spec/models/application_setting_spec.rb b/spec/models/application_setting_spec.rb
index 719eda9b5b3..f8c38ed8569 100644
--- a/spec/models/application_setting_spec.rb
+++ b/spec/models/application_setting_spec.rb
@@ -30,20 +30,16 @@ describe ApplicationSetting, models: true do
end
describe 'default_artifacts_expire_in' do
- it 'sets an error if it is invalid' do
+ it 'sets an error if it cannot parse' do
setting.update(default_artifacts_expire_in: 'a')
- expect(setting).to be_invalid
- expect(setting.errors.messages)
- .to have_key(:default_artifacts_expiration)
+ expect_invalid
end
- it 'does not allow 0' do
- setting.update(default_artifacts_expire_in: '0')
+ it 'sets an error if it is blank' do
+ setting.update(default_artifacts_expire_in: ' ')
- expect(setting).to be_invalid
- expect(setting.errors.messages)
- .to have_key(:default_artifacts_expiration)
+ expect_invalid
end
it 'sets the value if it is valid' do
@@ -53,11 +49,17 @@ describe ApplicationSetting, models: true do
expect(setting.default_artifacts_expire_in).to eq('30 days')
end
- it 'does not set it if it is blank' do
- setting.update(default_artifacts_expire_in: ' ')
+ it 'sets the value if it is 0' do
+ setting.update(default_artifacts_expire_in: '0')
expect(setting).to be_valid
- expect(setting.default_artifacts_expire_in).to be_nil
+ expect(setting.default_artifacts_expire_in).to eq('0')
+ end
+
+ def expect_invalid
+ expect(setting).to be_invalid
+ expect(setting.errors.messages)
+ .to have_key(:default_artifacts_expiration)
end
end