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
9639c058
Commit
9639c058
authored
Feb 10, 2022
by
Lin Jen-Shin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make sure #eql? will not raise when type unmatched
Also add a test for #eql?
parent
34bd156b
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
46 additions
and
2 deletions
+46
-2
ee/app/models/vulnerabilities/finding_signature.rb
ee/app/models/vulnerabilities/finding_signature.rb
+3
-2
ee/spec/models/vulnerabilities/finding_signature_spec.rb
ee/spec/models/vulnerabilities/finding_signature_spec.rb
+43
-0
No files found.
ee/app/models/vulnerabilities/finding_signature.rb
View file @
9639c058
...
...
@@ -20,8 +20,9 @@ module Vulnerabilities
end
def
eql?
(
other
)
other
.
algorithm_type
==
algorithm_type
&&
other
.
signature_sha
==
signature_sha
other
.
is_a?
(
self
.
class
)
&&
other
.
algorithm_type
==
algorithm_type
&&
other
.
signature_sha
==
signature_sha
end
alias_method
:==
,
:eql?
...
...
ee/spec/models/vulnerabilities/finding_signature_spec.rb
View file @
9639c058
...
...
@@ -31,4 +31,47 @@ RSpec.describe Vulnerabilities::FindingSignature do
it
{
is_expected
.
to
eq
([
expected_signature
])
}
end
describe
'#eql?'
do
context
'when the other is also a FindingSignature'
do
context
'when algorithm_type and signature_sha are the same'
do
let
(
:other
)
do
build
(
:vulnerabilities_finding_signature
,
signature_sha:
signature
.
signature_sha
,
algorithm_type:
signature
.
algorithm_type
)
end
it
'returns true'
do
expect
(
signature
.
eql?
(
other
)).
to
eq
(
true
)
end
end
context
'when algorithm_type is different'
do
let
(
:other
)
{
build
(
:vulnerabilities_finding_signature
,
:location
)
}
it
'returns false'
do
expect
(
signature
.
eql?
(
other
)).
to
eq
(
false
)
end
end
context
'when signature_sha is different'
do
let
(
:other
)
{
build
(
:vulnerabilities_finding_signature
)
}
before
do
other
.
signature_sha
=
other
.
signature_sha
.
reverse
end
it
'returns false'
do
expect
(
signature
.
eql?
(
other
)).
to
eq
(
false
)
end
end
end
context
'when the other is not a FindingSignature'
do
it
'returns false'
do
expect
(
signature
.
eql?
(
'something else'
)).
to
eq
(
false
)
end
end
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