BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
46082f4b
Commit
46082f4b
authored
Feb 16, 2017
by
Lin Jen-Shin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use static error message and don't give booleans
in validation. Feedback:
https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/9219#note_23437431
https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/9219#note_23437868
parent
3acf4fbe
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
8 additions
and
9 deletions
+8
-9
application_setting.rb
app/models/application_setting.rb
+4
-9
application_setting_spec.rb
spec/models/application_setting_spec.rb
+4
-0
No files found.
app/models/application_setting.rb
View file @
46082f4b
...
@@ -306,17 +306,12 @@ class ApplicationSetting < ActiveRecord::Base
...
@@ -306,17 +306,12 @@ class ApplicationSetting < ActiveRecord::Base
end
end
def
check_default_artifacts_expire_in
def
check_default_artifacts_expire_in
return
true
unless
default_artifacts_expire_in
if
default_artifacts_expire_in
&&
ChronicDuration
.
parse
(
default_artifacts_expire_in
).
nil?
if
ChronicDuration
.
parse
(
default_artifacts_expire_in
).
nil?
errors
.
add
(
:default_artifacts_expiration
,
errors
.
add
(
:default_artifacts_expire_in
,
"can't be 0. Leave it blank for no expiration"
)
"can't be 0. Leave it blank for no expiration"
)
false
else
true
end
end
rescue
ChronicDuration
::
DurationParseError
=>
e
rescue
ChronicDuration
::
DurationParseError
=>
e
errors
.
add
(
:default_artifacts_expire_in
,
":
#{
e
.
message
}
"
)
errors
.
add
(
:default_artifacts_expiration
,
"is invalid"
)
false
end
end
end
end
spec/models/application_setting_spec.rb
View file @
46082f4b
...
@@ -34,12 +34,16 @@ describe ApplicationSetting, models: true do
...
@@ -34,12 +34,16 @@ describe ApplicationSetting, models: true do
setting
.
update
(
default_artifacts_expire_in:
'a'
)
setting
.
update
(
default_artifacts_expire_in:
'a'
)
expect
(
setting
).
to
be_invalid
expect
(
setting
).
to
be_invalid
expect
(
setting
.
errors
.
messages
)
.
to
have_key
(
:default_artifacts_expiration
)
end
end
it
'does not allow 0'
do
it
'does not allow 0'
do
setting
.
update
(
default_artifacts_expire_in:
'0'
)
setting
.
update
(
default_artifacts_expire_in:
'0'
)
expect
(
setting
).
to
be_invalid
expect
(
setting
).
to
be_invalid
expect
(
setting
.
errors
.
messages
)
.
to
have_key
(
:default_artifacts_expiration
)
end
end
it
'sets the value if it is valid'
do
it
'sets the value if it is valid'
do
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment