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
b86756e1
Commit
b86756e1
authored
Sep 24, 2020
by
Mehmet Emin INAC
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Implement `latest_failed_security_builds` method on Ci::Pipeline
parent
185b5541
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
26 additions
and
0 deletions
+26
-0
ee/app/models/ee/ci/pipeline.rb
ee/app/models/ee/ci/pipeline.rb
+9
-0
ee/spec/models/ci/pipeline_spec.rb
ee/spec/models/ci/pipeline_spec.rb
+17
-0
No files found.
ee/app/models/ee/ci/pipeline.rb
View file @
b86756e1
...
...
@@ -160,6 +160,11 @@ module EE
merge_request_pipeline?
&&
merge_train_ref?
end
def
latest_failed_security_builds
security_builds
.
select
(
&
:latest?
)
.
select
(
&
:failed?
)
end
private
def
project_has_subscriptions?
...
...
@@ -175,6 +180,10 @@ module EE
feature_names
=
REPORT_LICENSED_FEATURES
.
fetch
(
file_type
)
feature_names
.
nil?
||
feature_names
.
any?
{
|
feature
|
project
.
feature_available?
(
feature
)
}
end
def
security_builds
@security_builds
||=
::
Security
::
SecurityJobsFinder
.
new
(
pipeline:
self
).
execute
end
end
end
end
ee/spec/models/ci/pipeline_spec.rb
View file @
b86756e1
...
...
@@ -495,4 +495,21 @@ RSpec.describe Ci::Pipeline do
it
{
is_expected
.
to
eq
(
:detached
)
}
end
end
describe
'#latest_failed_security_builds'
do
let
(
:sast_build
)
{
create
(
:ee_ci_build
,
:sast
,
:failed
,
pipeline:
pipeline
)
}
let
(
:dast_build
)
{
create
(
:ee_ci_build
,
:sast
,
pipeline:
pipeline
)
}
let
(
:retried_sast_build
)
{
create
(
:ee_ci_build
,
:sast
,
:failed
,
:retried
,
pipeline:
pipeline
)
}
let
(
:expected_builds
)
{
[
sast_build
]
}
before
do
allow_next_instance_of
(
::
Security
::
SecurityJobsFinder
)
do
|
finder
|
allow
(
finder
).
to
receive
(
:execute
).
and_return
([
sast_build
,
dast_build
,
retried_sast_build
])
end
end
subject
{
pipeline
.
latest_failed_security_builds
}
it
{
is_expected
.
to
match_array
(
expected_builds
)
}
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