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
1d67b449
Commit
1d67b449
authored
Apr 30, 2021
by
Philip Cunningham
Committed by
Alex Kalderimis
Apr 30, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Extract shared example for Dast::Profile spec
parent
770b0fb8
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
18 deletions
+19
-18
ee/spec/models/dast/profile_spec.rb
ee/spec/models/dast/profile_spec.rb
+19
-18
No files found.
ee/spec/models/dast/profile_spec.rb
View file @
1d67b449
...
...
@@ -27,30 +27,31 @@ RSpec.describe Dast::Profile, type: :model do
it
{
is_expected
.
to
validate_presence_of
(
:dast_scanner_profile_id
)
}
it
{
is_expected
.
to
validate_presence_of
(
:name
)
}
context
'when the project_id and dast_site_profile.project_id do
not match'
do
let
(
:
dast_site_profile
)
{
create
(
:dast_site_profile
)
}
shared_examples
'the project_id does
not match'
do
let
(
:
association_name
)
{
association
.
class
.
underscore
}
subject
{
build
(
:dast_profile
,
project:
project
,
dast_site_profile:
dast_site_profile
)
}
subject
{
build
(
:dast_profile
,
project:
project
,
association_name
=>
association
)
}
it
'is not valid'
do
aggregate_failures
do
expect
(
subject
.
valid?
).
to
be_falsey
expect
(
subject
.
errors
.
full_messages
).
to
include
(
'Project must match dast_site_profile.project_id'
)
before
do
association
.
project_id
=
non_existing_record_id
end
it
'is not valid'
,
:aggregate_failures
do
expect
(
subject
).
not_to
be_valid
expect
(
subject
.
errors
.
full_messages
).
to
include
(
"Project must match
#{
association_name
}
.project_id"
)
end
end
context
'when the project_id and dast_scanner_profile.project_id do not match'
do
let
(
:dast_scanner_profile
)
{
create
(
:dast_scanner_profile
)
}
subject
{
build
(
:dast_profile
,
project:
project
,
dast_scanner_profile:
dast_scanner_profile
)
}
context
'when the project_id and dast_site_profile.project_id do not match'
do
let
(
:association
)
{
build
(
:dast_site_profile
)
}
it
'is not valid'
do
aggregate_failures
do
expect
(
subject
.
valid?
).
to
be_falsey
expect
(
subject
.
errors
.
full_messages
).
to
include
(
'Project must match dast_scanner_profile.project_id'
)
end
it_behaves_like
'the project_id does not match'
end
context
'when the project_id and dast_scanner_profile.project_id do not match'
do
let
(
:association
)
{
build
(
:dast_scanner_profile
)
}
it_behaves_like
'the project_id does not match'
end
context
'when the description is nil'
do
...
...
@@ -58,7 +59,7 @@ RSpec.describe Dast::Profile, type: :model do
it
'is not valid'
do
aggregate_failures
do
expect
(
subject
.
valid?
).
to
be_falsey
expect
(
subject
).
not_to
be_valid
expect
(
subject
.
errors
.
full_messages
).
to
include
(
'Description can\'t be nil'
)
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