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
1e79c80e
Commit
1e79c80e
authored
Oct 16, 2020
by
Michał Zając
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove reference prefix from Vulnerability
parent
c8c78bfb
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
0 additions
and
95 deletions
+0
-95
app/models/vulnerability.rb
app/models/vulnerability.rb
+0
-10
ee/spec/models/ee/vulnerability_spec.rb
ee/spec/models/ee/vulnerability_spec.rb
+0
-85
No files found.
app/models/vulnerability.rb
View file @
1e79c80e
# frozen_string_literal: true
# Placeholder class for model that is implemented in EE
# It reserves '+' as a reference prefix, but the table does not exist in FOSS
class
Vulnerability
<
ApplicationRecord
include
IgnorableColumns
def
self
.
reference_prefix
'+'
end
def
self
.
reference_prefix_escaped
'+'
end
end
Vulnerability
.
prepend_if_ee
(
'EE::Vulnerability'
)
ee/spec/models/ee/vulnerability_spec.rb
View file @
1e79c80e
...
...
@@ -492,91 +492,6 @@ RSpec.describe Vulnerability do
it
{
is_expected
.
to
eq
(
'critical'
=>
6
,
'high'
=>
4
,
'info'
=>
1
,
'low'
=>
5
,
'medium'
=>
2
,
'unknown'
=>
3
)
}
end
describe
'.reference_prefix'
do
subject
{
described_class
.
reference_prefix
}
it
{
is_expected
.
to
eq
(
'+'
)
}
end
describe
'#to_reference'
do
let
(
:namespace
)
{
build
(
:namespace
,
path:
'sample-namespace'
)
}
let
(
:project
)
{
build
(
:project
,
name:
'sample-project'
,
namespace:
namespace
)
}
let
(
:vulnerability
)
{
build
(
:vulnerability
,
id:
1
,
project:
project
)
}
context
'when nil argument'
do
it
'returns vulnerability id'
do
expect
(
vulnerability
.
to_reference
).
to
eq
'+1'
end
it
'returns complete path to the vulnerability with full: true'
do
expect
(
vulnerability
.
to_reference
(
full:
true
)).
to
eq
'sample-namespace/sample-project+1'
end
end
context
'when argument is a project'
do
context
'when same project'
do
it
'returns vulnerability id'
do
expect
(
vulnerability
.
to_reference
(
project
)).
to
eq
(
'+1'
)
end
it
'returns full reference with full: true'
do
expect
(
vulnerability
.
to_reference
(
project
,
full:
true
)).
to
eq
'sample-namespace/sample-project+1'
end
end
context
'when cross-project in same namespace'
do
let
(
:another_project
)
do
build
(
:project
,
name:
'another-project'
,
namespace:
project
.
namespace
)
end
it
'returns a cross-project reference'
do
expect
(
vulnerability
.
to_reference
(
another_project
)).
to
eq
'sample-project+1'
end
it
'returns full reference with full: true'
do
expect
(
vulnerability
.
to_reference
(
another_project
,
full:
true
)).
to
eq
'sample-namespace/sample-project+1'
end
end
context
'when cross-project in different namespace'
do
let
(
:another_namespace
)
{
build
(
:namespace
,
path:
'another-namespace'
)
}
let
(
:another_namespace_project
)
{
build
(
:project
,
path:
'another-project'
,
namespace:
another_namespace
)
}
it
'returns complete path to the vulnerability'
do
expect
(
vulnerability
.
to_reference
(
another_namespace_project
)).
to
eq
'sample-namespace/sample-project+1'
end
it
'returns full reference with full: true'
do
expect
(
vulnerability
.
to_reference
(
another_namespace_project
,
full:
true
)).
to
eq
'sample-namespace/sample-project+1'
end
end
end
context
'when argument is a namespace'
do
context
'when same as vulnerability'
do
it
'returns path to the vulnerability with the project name'
do
expect
(
vulnerability
.
to_reference
(
namespace
)).
to
eq
'sample-project+1'
end
it
'returns full reference with full: true'
do
expect
(
vulnerability
.
to_reference
(
namespace
,
full:
true
)).
to
eq
'sample-namespace/sample-project+1'
end
end
context
'when different from vulnerability namespace'
do
let
(
:group
)
{
build
(
:group
,
name:
'Group'
,
path:
'sample-group'
)
}
it
'returns full path to the vulnerability with full: true'
do
expect
(
vulnerability
.
to_reference
(
group
)).
to
eq
'sample-namespace/sample-project+1'
end
it
'returns full path to the vulnerability with full: false'
do
expect
(
vulnerability
.
to_reference
(
group
,
full:
false
)).
to
eq
'sample-namespace/sample-project+1'
end
end
end
end
describe
'#finding'
do
let_it_be
(
:project
)
{
create
(
:project
,
:with_vulnerability
)
}
let_it_be
(
:vulnerability
)
{
project
.
vulnerabilities
.
first
}
...
...
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