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
02b1c3e9
Commit
02b1c3e9
authored
Dec 05, 2019
by
allison.browne
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor error tracking spec
Use rspec validation matchers
parent
7fa306b9
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
61 deletions
+15
-61
spec/models/error_tracking/project_error_tracking_setting_spec.rb
...els/error_tracking/project_error_tracking_setting_spec.rb
+15
-61
No files found.
spec/models/error_tracking/project_error_tracking_setting_spec.rb
View file @
02b1c3e9
...
@@ -5,7 +5,7 @@ require 'spec_helper'
...
@@ -5,7 +5,7 @@ require 'spec_helper'
describe
ErrorTracking
::
ProjectErrorTrackingSetting
do
describe
ErrorTracking
::
ProjectErrorTrackingSetting
do
include
ReactiveCachingHelpers
include
ReactiveCachingHelpers
set
(
:project
)
{
create
(
:project
)
}
let_it_be
(
:project
)
{
create
(
:project
)
}
subject
{
create
(
:project_error_tracking_setting
,
project:
project
)
}
subject
{
create
(
:project_error_tracking_setting
,
project:
project
)
}
...
@@ -14,23 +14,23 @@ describe ErrorTracking::ProjectErrorTrackingSetting do
...
@@ -14,23 +14,23 @@ describe ErrorTracking::ProjectErrorTrackingSetting do
end
end
describe
'Validations'
do
describe
'Validations'
do
context
'when api_url is over 255 chars'
do
it
{
is_expected
.
to
validate_length_of
(
:api_url
).
is_at_most
(
255
)
}
before
do
it
{
is_expected
.
to
allow_values
(
"http://gitlab.com/api/0/projects/project1/something"
).
for
(
:api_url
)
}
subject
.
api_url
=
'https://'
+
'a'
*
250
end
it
'fails validation'
do
it
'rejects invalid api_urls'
do
expect
(
subject
).
not_to
be_valid
is_expected
.
not_to
allow_values
(
expect
(
subject
.
errors
.
messages
[
:api_url
]).
to
include
(
'is too long (maximum is 255 characters)'
)
"https://replaceme.com/'><script>alert(document.cookie)</script>"
,
# unsafe
end
"http://gitlab.com/project1/something"
,
# missing api/0/projects
"http://gitlab.com/api/0/projects/org/proj/something"
,
# extra segments
"http://gitlab.com/api/0/projects/org"
# too few segments
).
for
(
:api_url
).
with_message
(
'is invalid'
)
end
end
context
'With unsafe url'
do
it
'fails validation without org and project slugs'
do
it
'fails validation'
do
subject
.
api_url
=
'http://gitlab.com/api/0/projects/'
subject
.
api_url
=
"https://replaceme.com/'><script>alert(document.cookie)</script>"
expect
(
subject
).
not_to
be_valid
expect
(
subject
).
not_to
be_valid
e
nd
e
xpect
(
subject
.
errors
.
messages
[
:project
]).
to
include
(
'is a required field'
)
end
end
context
'presence validations'
do
context
'presence validations'
do
...
@@ -60,52 +60,6 @@ describe ErrorTracking::ProjectErrorTrackingSetting do
...
@@ -60,52 +60,6 @@ describe ErrorTracking::ProjectErrorTrackingSetting do
it
{
expect
(
subject
.
valid?
).
to
eq
(
valid?
)
}
it
{
expect
(
subject
.
valid?
).
to
eq
(
valid?
)
}
end
end
end
end
context
'URL path'
do
it
'fails validation without api/0/projects'
do
subject
.
api_url
=
'http://gitlab.com/project1/something'
expect
(
subject
).
not_to
be_valid
expect
(
subject
.
errors
.
messages
[
:api_url
]).
to
include
(
'is invalid'
)
end
it
'fails validation without org and project slugs'
do
subject
.
api_url
=
'http://gitlab.com/api/0/projects/'
expect
(
subject
).
not_to
be_valid
expect
(
subject
.
errors
.
messages
[
:project
]).
to
include
(
'is a required field'
)
end
it
'fails validation when api_url has extra parts'
do
subject
.
api_url
=
'http://gitlab.com/api/0/projects/org/proj/something'
expect
(
subject
).
not_to
be_valid
expect
(
subject
.
errors
.
messages
[
:api_url
]).
to
include
(
"is invalid"
)
end
it
'fails validation when api_url has less parts'
do
subject
.
api_url
=
'http://gitlab.com/api/0/projects/org'
expect
(
subject
).
not_to
be_valid
expect
(
subject
.
errors
.
messages
[
:api_url
]).
to
include
(
"is invalid"
)
end
it
'passes validation with correct path'
do
subject
.
api_url
=
'http://gitlab.com/api/0/projects/project1/something'
expect
(
subject
).
to
be_valid
end
end
context
'non ascii chars in api_url'
do
before
do
subject
.
api_url
=
'http://gitlab.com/api/0/projects/project1/something€'
end
it
'fails validation'
do
expect
(
subject
).
not_to
be_valid
end
end
end
end
describe
'#sentry_external_url'
do
describe
'#sentry_external_url'
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