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
70a421b4
Commit
70a421b4
authored
Jun 02, 2021
by
Mehmet Emin INAC
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor `Project#latest_pipeline_with_security_reports` spec
parent
c478e875
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
42 additions
and
56 deletions
+42
-56
ee/spec/models/project_spec.rb
ee/spec/models/project_spec.rb
+42
-56
No files found.
ee/spec/models/project_spec.rb
View file @
70a421b4
...
...
@@ -1687,28 +1687,15 @@ RSpec.describe Project do
end
describe
'#latest_pipeline_with_security_reports'
do
let
(
:only_successful
)
{
false
}
let_it_be
(
:project
)
{
create
(
:project
)
}
let_it_be
(
:project
,
refind:
true
)
{
create
(
:project
)
}
let_it_be
(
:pipeline_1
)
{
create
(
:ci_pipeline
,
:success
,
project:
project
)
}
let_it_be
(
:pipeline_2
)
{
create
(
:ci_pipeline
,
project:
project
)
}
let_it_be
(
:pipeline_3
)
{
create
(
:ci_pipeline
,
:success
,
project:
project
)
}
subject
{
project
.
latest_pipeline_with_security_reports
(
only_successful:
only_successful
)
}
context
'when all pipelines are used'
do
context
'when the pipeline of `vulnerability_statistic` has been set'
do
before
do
project
.
create_vulnerability_statistic
(
pipeline:
pipeline_1
)
end
it
{
is_expected
.
to
eq
(
pipeline_1
)
}
end
context
'when the pipeline of `vulnerability_statistic` has not been set'
do
before
do
project
.
vulnerability_statistic
&
.
update!
(
pipeline:
nil
)
end
shared_examples_for
'on-the-fly latest_pipeline_with_security_reports calculation'
do
|
expected
:|
let
(
:expected_pipeline
)
{
public_send
(
expected
)
}
context
'when legacy reports are used'
do
before
do
...
...
@@ -1717,7 +1704,7 @@ RSpec.describe Project do
end
it
'returns the latest pipeline with security reports'
do
is_expected
.
to
eq
(
pipeline_2
)
is_expected
.
to
eq
(
expected_pipeline
)
end
end
...
...
@@ -1728,7 +1715,7 @@ RSpec.describe Project do
end
it
'returns the latest pipeline with security reports'
do
is_expected
.
to
eq
(
pipeline_2
)
is_expected
.
to
eq
(
expected_pipeline
)
end
context
'when legacy used'
do
...
...
@@ -1737,47 +1724,46 @@ RSpec.describe Project do
end
it
'prefers the new reports'
do
is_expected
.
to
eq
(
pipeline_2
)
end
is_expected
.
to
eq
(
expected_pipeline
)
end
end
end
end
context
'when
only successfu
l pipelines are used'
do
let
(
:only_successful
)
{
tru
e
}
context
'when
al
l pipelines are used'
do
let
(
:only_successful
)
{
fals
e
}
context
'when legacy reports are used'
do
before
do
create
(
:ee_ci_build
,
:legacy_sast
,
pipeline:
pipeline_1
)
create
(
:ee_ci_build
,
:legacy_sast
,
pipeline:
pipeline_2
)
context
'when there is no associated `vulnerability_statistic` record with the project'
do
it_behaves_like
'on-the-fly latest_pipeline_with_security_reports calculation'
,
expected: :pipeline_2
end
it
"returns the latest succesful pipeline with security reports"
do
is_expected
.
to
eq
(
pipeline_1
)
context
'when there is an associated `vulnerability_statistic` record with the project'
do
context
'when the pipeline of `vulnerability_statistic` has not been set'
do
it_behaves_like
'on-the-fly latest_pipeline_with_security_reports calculation'
,
expected: :pipeline_2
do
before
do
create
(
:vulnerability_statistic
,
project:
project
,
pipeline:
nil
)
end
end
end
context
'when new reports are used
'
do
context
'when the pipeline of `vulnerability_statistic` has been set
'
do
before
do
create
(
:ee_ci_build
,
:sast
,
pipeline:
pipeline_1
)
create
(
:ee_ci_build
,
:sast
,
pipeline:
pipeline_2
)
create
(
:vulnerability_statistic
,
project:
project
,
pipeline:
pipeline_1
)
end
it
'returns the latest successful pipeline with security reports'
do
is_expected
.
to
eq
(
pipeline_1
)
it
{
is_expected
.
to
eq
(
pipeline_1
)
}
end
end
end
context
'when legacy used'
do
context
'when only successful pipelines are used'
do
let
(
:only_successful
)
{
true
}
before
do
create
(
:ee_ci_build
,
:legacy_sast
,
pipeline:
pipeline_3
)
create
(
:vulnerability_statistic
,
project:
project
,
pipeline:
pipeline_2
)
end
it
'prefers the new reports'
do
is_expected
.
to
eq
(
pipeline_1
)
end
end
end
it_behaves_like
'on-the-fly latest_pipeline_with_security_reports calculation'
,
expected: :pipeline_1
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