Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Jérome Perrin
gitlab-ce
Commits
602f3b84
Commit
602f3b84
authored
Feb 15, 2017
by
Lin Jen-Shin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add a few more tests and make sure empty value sets to nil
parent
4eff5eb8
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
39 additions
and
2 deletions
+39
-2
app/models/application_setting.rb
app/models/application_setting.rb
+8
-0
spec/models/application_setting_spec.rb
spec/models/application_setting_spec.rb
+22
-0
spec/requests/api/settings_spec.rb
spec/requests/api/settings_spec.rb
+9
-2
No files found.
app/models/application_setting.rb
View file @
602f3b84
...
...
@@ -269,6 +269,14 @@ class ApplicationSetting < ActiveRecord::Base
self
.
repository_storages
=
[
value
]
end
def
default_artifacts_expire_in
=
(
value
)
if
value
.
present?
super
(
value
.
strip
)
else
super
(
nil
)
end
end
# Choose one of the available repository storage options. Currently all have
# equal weighting.
def
pick_repository_storage
...
...
spec/models/application_setting_spec.rb
View file @
602f3b84
...
...
@@ -29,6 +29,28 @@ describe ApplicationSetting, models: true do
it
{
is_expected
.
not_to
allow_value
([
'test'
]).
for
(
:disabled_oauth_sign_in_sources
)
}
end
describe
'default_artifacts_expire_in'
do
it
'sets an error if it is invalid'
do
setting
.
update
(
default_artifacts_expire_in:
'a'
)
expect
(
setting
).
to
be_invalid
end
it
'sets the value if it is valid'
do
setting
.
update
(
default_artifacts_expire_in:
'30 days'
)
expect
(
setting
).
to
be_valid
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:
' '
)
expect
(
setting
).
to
be_valid
expect
(
setting
.
default_artifacts_expire_in
).
to
be_nil
end
end
it
{
is_expected
.
to
validate_presence_of
(
:max_attachment_size
)
}
it
do
...
...
spec/requests/api/settings_spec.rb
View file @
602f3b84
...
...
@@ -30,8 +30,14 @@ describe API::Settings, 'Settings', api: true do
it
"updates application settings"
do
put
api
(
"/application/settings"
,
admin
),
default_projects_limit:
3
,
signin_enabled:
false
,
repository_storage:
'custom'
,
koding_enabled:
true
,
koding_url:
'http://koding.example.com'
,
plantuml_enabled:
true
,
plantuml_url:
'http://plantuml.example.com'
default_projects_limit:
3
,
signin_enabled:
false
,
repository_storage:
'custom'
,
koding_enabled:
true
,
koding_url:
'http://koding.example.com'
,
plantuml_enabled:
true
,
plantuml_url:
'http://plantuml.example.com'
,
default_artifacts_expire_in:
'2 days'
expect
(
response
).
to
have_http_status
(
200
)
expect
(
json_response
[
'default_projects_limit'
]).
to
eq
(
3
)
expect
(
json_response
[
'signin_enabled'
]).
to
be_falsey
...
...
@@ -41,6 +47,7 @@ describe API::Settings, 'Settings', api: true do
expect
(
json_response
[
'koding_url'
]).
to
eq
(
'http://koding.example.com'
)
expect
(
json_response
[
'plantuml_enabled'
]).
to
be_truthy
expect
(
json_response
[
'plantuml_url'
]).
to
eq
(
'http://plantuml.example.com'
)
expect
(
json_response
[
'default_artifacts_expire_in'
]).
to
eq
(
'2 days'
)
end
end
...
...
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