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
1
Merge Requests
1
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
nexedi
gitlab-ce
Commits
838b4726
Commit
838b4726
authored
Nov 04, 2021
by
Marius Bobin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Validate attributes length
parent
d55be96c
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
34 additions
and
13 deletions
+34
-13
app/models/application_setting.rb
app/models/application_setting.rb
+3
-3
ee/spec/models/application_setting_spec.rb
ee/spec/models/application_setting_spec.rb
+31
-10
No files found.
app/models/application_setting.rb
View file @
838b4726
...
...
@@ -539,13 +539,13 @@ class ApplicationSetting < ApplicationRecord
validates
:sentry_enabled
,
inclusion:
{
in:
[
true
,
false
],
message:
_
(
'must be a boolean value'
)
}
validates
:sentry_dsn
,
addressable_url:
true
,
presence:
true
,
addressable_url:
true
,
presence:
true
,
length:
{
maximum:
255
},
if: :sentry_enabled?
validates
:sentry_clientside_dsn
,
addressable_url:
true
,
allow_blank:
true
,
addressable_url:
true
,
allow_blank:
true
,
length:
{
maximum:
255
},
if: :sentry_enabled?
validates
:sentry_environment
,
presence:
true
,
presence:
true
,
length:
{
maximum:
255
},
if: :sentry_enabled?
attr_encrypted
:asset_proxy_secret_key
,
...
...
ee/spec/models/application_setting_spec.rb
View file @
838b4726
...
...
@@ -180,18 +180,39 @@ RSpec.describe ApplicationSetting do
end
context
'Sentry validations'
do
before
do
setting
.
sentry_enabled
=
true
context
'when Sentry is enabled'
do
before
do
setting
.
sentry_enabled
=
true
end
it
{
is_expected
.
to
allow_value
(
false
).
for
(
:sentry_enabled
)
}
it
{
is_expected
.
not_to
allow_value
(
nil
).
for
(
:sentry_enabled
)
}
it
{
is_expected
.
to
allow_value
(
'http://example.com'
).
for
(
:sentry_dsn
)
}
it
{
is_expected
.
not_to
allow_value
(
"http://
#{
'a'
*
255
}
.com"
).
for
(
:sentry_dsn
)
}
it
{
is_expected
.
not_to
allow_value
(
'example'
).
for
(
:sentry_dsn
)
}
it
{
is_expected
.
not_to
allow_value
(
nil
).
for
(
:sentry_dsn
)
}
it
{
is_expected
.
to
allow_value
(
'http://example.com'
).
for
(
:sentry_clientside_dsn
)
}
it
{
is_expected
.
to
allow_value
(
nil
).
for
(
:sentry_clientside_dsn
)
}
it
{
is_expected
.
not_to
allow_value
(
'example'
).
for
(
:sentry_clientside_dsn
)
}
it
{
is_expected
.
not_to
allow_value
(
"http://
#{
'a'
*
255
}
.com"
).
for
(
:sentry_clientside_dsn
)
}
it
{
is_expected
.
to
allow_value
(
'production'
).
for
(
:sentry_environment
)
}
it
{
is_expected
.
not_to
allow_value
(
nil
).
for
(
:sentry_environment
)
}
it
{
is_expected
.
not_to
allow_value
(
'a'
*
256
).
for
(
:sentry_environment
)
}
end
it
{
is_expected
.
to
allow_value
(
false
).
for
(
:sentry_enabled
)
}
it
{
is_expected
.
not_to
allow_value
(
nil
).
for
(
:sentry_enabled
)
}
it
{
is_expected
.
to
allow_value
(
'http://example.com'
).
for
(
:sentry_dsn
)
}
it
{
is_expected
.
not_to
allow_value
(
'example'
).
for
(
:sentry_dsn
)
}
it
{
is_expected
.
to
allow_value
(
'http://example.com'
).
for
(
:sentry_clientside_dsn
)
}
it
{
is_expected
.
not_to
allow_value
(
'example'
).
for
(
:sentry_clientside_dsn
)
}
it
{
is_expected
.
to
allow_value
(
'production'
).
for
(
:sentry_environment
)
}
it
{
is_expected
.
not_to
allow_value
(
nil
).
for
(
:sentry_environment
)
}
context
'when Sentry is disabled'
do
before
do
setting
.
sentry_enabled
=
false
end
it
{
is_expected
.
not_to
allow_value
(
nil
).
for
(
:sentry_enabled
)
}
it
{
is_expected
.
to
allow_value
(
nil
).
for
(
:sentry_dsn
)
}
it
{
is_expected
.
to
allow_value
(
nil
).
for
(
:sentry_clientside_dsn
)
}
it
{
is_expected
.
to
allow_value
(
nil
).
for
(
:sentry_environment
)
}
end
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