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
176be8c0
Commit
176be8c0
authored
Feb 06, 2020
by
Daniel Paul Searles
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove rubocop ignore
parent
94afc015
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
40 additions
and
4 deletions
+40
-4
ee/app/controllers/projects/vulnerability_feedback_controller.rb
...controllers/projects/vulnerability_feedback_controller.rb
+2
-4
ee/app/models/vulnerabilities/feedback.rb
ee/app/models/vulnerabilities/feedback.rb
+8
-0
ee/spec/models/vulnerabilities/feedback_spec.rb
ee/spec/models/vulnerabilities/feedback_spec.rb
+30
-0
No files found.
ee/app/controllers/projects/vulnerability_feedback_controller.rb
View file @
176be8c0
...
...
@@ -11,24 +11,22 @@ class Projects::VulnerabilityFeedbackController < Projects::ApplicationControlle
respond_to
:json
# rubocop: disable CodeReuse/ActiveRecord
def
index
# TODO: Move to finder or list service
@vulnerability_feedback
=
@project
.
vulnerability_feedback
.
with_associations
if
params
[
:category
].
present?
@vulnerability_feedback
=
@vulnerability_feedback
.
w
here
(
category:
Vulnerabilities
::
Feedback
.
categories
[
params
[
:category
]
])
.
w
ith_category
(
params
[
:category
])
end
if
params
[
:feedback_type
].
present?
@vulnerability_feedback
=
@vulnerability_feedback
.
w
here
(
feedback_type:
Vulnerabilities
::
Feedback
.
feedback_types
[
params
[
:feedback_type
]
])
.
w
ith_feedback_type
(
params
[
:feedback_type
])
end
render
json:
serializer
.
represent
(
@vulnerability_feedback
)
end
# rubocop: enable CodeReuse/ActiveRecord
def
create
service
=
VulnerabilityFeedback
::
CreateService
.
new
(
project
,
current_user
,
vulnerability_feedback_params
)
...
...
ee/app/models/vulnerabilities/feedback.rb
View file @
176be8c0
...
...
@@ -54,6 +54,14 @@ module Vulnerabilities
end
end
def
self
.
with_category
(
category
)
where
(
category:
category
)
end
def
self
.
with_feedback_type
(
feedback_type
)
where
(
feedback_type:
feedback_type
)
end
# A hard delete of the comment_author will cause the comment_author to be nil, but the comment
# will still exist.
def
has_comment?
...
...
ee/spec/models/vulnerabilities/feedback_spec.rb
View file @
176be8c0
...
...
@@ -41,6 +41,36 @@ describe Vulnerabilities::Feedback do
end
end
describe
'.with_category'
do
it
'filters by category'
do
described_class
.
categories
.
each
do
|
category
,
_
|
create
(
:vulnerability_feedback
,
category:
category
)
end
expect
(
described_class
.
count
).
to
eq
described_class
.
categories
.
length
expected
,
_
=
described_class
.
categories
.
first
feedback
=
described_class
.
with_category
(
expected
)
expect
(
feedback
.
length
).
to
eq
1
expect
(
feedback
.
first
.
category
).
to
eq
expected
end
end
describe
'.with_feedback_type'
do
it
'filters by feedback_type'
do
create
(
:vulnerability_feedback
,
:dismissal
)
create
(
:vulnerability_feedback
,
:issue
)
create
(
:vulnerability_feedback
,
:merge_request
)
feedback
=
described_class
.
with_feedback_type
(
'issue'
)
expect
(
feedback
.
length
).
to
eq
1
expect
(
feedback
.
first
.
feedback_type
).
to
eq
'issue'
end
end
describe
'#has_comment?'
do
let
(
:feedback
)
{
build
(
:vulnerability_feedback
,
comment:
comment
,
comment_author:
comment_author
)
}
let
(
:comment
)
{
'a comment'
}
...
...
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