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
870ea48a
Commit
870ea48a
authored
May 31, 2021
by
GitLab Bot
Browse files
Options
Browse Files
Download
Plain Diff
Automatic merge of gitlab-org/gitlab master
parents
adf9488c
ce4d1a57
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
82 additions
and
3 deletions
+82
-3
app/models/merge_request.rb
app/models/merge_request.rb
+1
-0
ee/app/assets/javascripts/vulnerabilities/components/generic_report/types/constants.js
...nerabilities/components/generic_report/types/constants.js
+2
-0
ee/app/assets/javascripts/vulnerabilities/components/generic_report/types/file_location.vue
...ilities/components/generic_report/types/file_location.vue
+28
-0
ee/spec/frontend/vulnerabilities/generic_report/report_item_spec.js
...ontend/vulnerabilities/generic_report/report_item_spec.js
+6
-1
ee/spec/frontend/vulnerabilities/generic_report/types/file_location_spec.js
...ulnerabilities/generic_report/types/file_location_spec.js
+35
-0
spec/models/merge_request_spec.rb
spec/models/merge_request_spec.rb
+10
-2
No files found.
app/models/merge_request.rb
View file @
870ea48a
...
...
@@ -269,6 +269,7 @@ class MergeRequest < ApplicationRecord
scope
:merged
,
->
{
with_state
(
:merged
)
}
scope
:closed_and_merged
,
->
{
with_states
(
:closed
,
:merged
)
}
scope
:open_and_closed
,
->
{
with_states
(
:opened
,
:closed
)
}
scope
:drafts
,
->
{
where
(
draft:
true
)
}
scope
:from_source_branches
,
->
(
branches
)
{
where
(
source_branch:
branches
)
}
scope
:by_commit_sha
,
->
(
sha
)
do
where
(
'EXISTS (?)'
,
MergeRequestDiff
.
select
(
1
).
where
(
'merge_requests.latest_merge_request_diff_id = merge_request_diffs.id'
).
by_commit_sha
(
sha
)).
reorder
(
nil
)
...
...
ee/app/assets/javascripts/vulnerabilities/components/generic_report/types/constants.js
View file @
870ea48a
...
...
@@ -8,6 +8,7 @@ export const REPORT_TYPES = {
text
:
'
text
'
,
value
:
'
value
'
,
moduleLocation
:
'
module-location
'
,
fileLocation
:
'
file-location
'
,
};
const
REPORT_TYPE_TO_COMPONENT_MAP
=
{
...
...
@@ -18,6 +19,7 @@ const REPORT_TYPE_TO_COMPONENT_MAP = {
[
REPORT_TYPES
.
text
]:
()
=>
import
(
'
./value.vue
'
),
[
REPORT_TYPES
.
value
]:
()
=>
import
(
'
./value.vue
'
),
[
REPORT_TYPES
.
moduleLocation
]:
()
=>
import
(
'
./module_location.vue
'
),
[
REPORT_TYPES
.
fileLocation
]:
()
=>
import
(
'
./file_location.vue
'
),
};
export
const
getComponentNameForType
=
(
reportType
)
=>
...
...
ee/app/assets/javascripts/vulnerabilities/components/generic_report/types/file_location.vue
0 → 100644
View file @
870ea48a
<
script
>
export
default
{
inheritAttrs
:
false
,
props
:
{
fileName
:
{
type
:
String
,
required
:
true
,
},
lineStart
:
{
type
:
Number
,
required
:
true
,
},
lineEnd
:
{
type
:
Number
,
required
:
false
,
default
:
null
,
},
},
computed
:
{
lineStr
()
{
return
this
.
lineEnd
?
`
${
this
.
lineStart
}
-
${
this
.
lineEnd
}
`
:
this
.
lineStart
;
},
},
};
</
script
>
<
template
>
<span>
{{
fileName
}}
:
{{
lineStr
}}
</span>
</
template
>
ee/spec/frontend/vulnerabilities/generic_report/report_item_spec.js
View file @
870ea48a
...
...
@@ -26,9 +26,14 @@ const TEST_DATA = {
value
:
15
,
},
[
REPORT_TYPES
.
moduleName
]:
{
'
module-name
'
:
'
foo.c
'
,
moduleName
:
'
foo.c
'
,
offset
:
15
,
},
[
REPORT_TYPES
.
fileLocation
]:
{
fileName
:
'
index.js
'
,
lineStart
:
'
1
'
,
lineEnd
:
'
2
'
,
},
};
describe
(
'
ee/vulnerabilities/components/generic_report/report_item.vue
'
,
()
=>
{
...
...
ee/spec/frontend/vulnerabilities/generic_report/types/file_location_spec.js
0 → 100644
View file @
870ea48a
import
{
shallowMount
}
from
'
@vue/test-utils
'
;
import
FileLocation
from
'
ee/vulnerabilities/components/generic_report/types/file_location.vue
'
;
describe
(
'
ee/vulnerabilities/components/generic_report/types/file_location.vue
'
,
()
=>
{
let
wrapper
;
describe
.
each
`
fileName | lineStart | lineEnd | value
${
'
foo.c
'
}
|
${
4
}
|
${
undefined
}
|
${
'
foo.c:4
'
}
${
'
bar.go
'
}
|
${
2
}
|
${
5
}
|
${
'
bar.go:2-5
'
}
`
(
'
with value of type "$fieldType"
'
,
({
fileName
,
lineStart
,
lineEnd
,
value
})
=>
{
const
createWrapper
=
()
=>
{
return
shallowMount
(
FileLocation
,
{
propsData
:
{
type
:
'
file-location
'
,
fileName
,
lineStart
,
lineEnd
,
},
});
};
beforeEach
(()
=>
{
wrapper
=
createWrapper
();
});
afterEach
(()
=>
{
wrapper
.
destroy
();
});
it
(
`renders
${
fileName
}
file location`
,
()
=>
{
expect
(
wrapper
.
text
()).
toBe
(
value
.
toString
());
});
});
});
spec/models/merge_request_spec.rb
View file @
870ea48a
...
...
@@ -99,6 +99,7 @@ RSpec.describe MergeRequest, factory_default: :keep do
let_it_be
(
:merge_request1
)
{
create
(
:merge_request
,
:unique_branches
,
reviewers:
[
user1
])}
let_it_be
(
:merge_request2
)
{
create
(
:merge_request
,
:unique_branches
,
reviewers:
[
user2
])}
let_it_be
(
:merge_request3
)
{
create
(
:merge_request
,
:unique_branches
,
reviewers:
[])}
let_it_be
(
:merge_request4
)
{
create
(
:merge_request
,
:draft_merge_request
)}
describe
'.review_requested'
do
it
'returns MRs that have any review requests'
do
...
...
@@ -108,7 +109,7 @@ RSpec.describe MergeRequest, factory_default: :keep do
describe
'.no_review_requested'
do
it
'returns MRs that have no review requests'
do
expect
(
described_class
.
no_review_requested
).
to
eq
([
merge_request3
])
expect
(
described_class
.
no_review_requested
).
to
eq
([
merge_request3
,
merge_request4
])
end
end
...
...
@@ -120,7 +121,14 @@ RSpec.describe MergeRequest, factory_default: :keep do
describe
'.no_review_requested_to'
do
it
'returns MRs that the user has not been requested to review'
do
expect
(
described_class
.
no_review_requested_to
(
user1
)).
to
eq
([
merge_request2
,
merge_request3
])
expect
(
described_class
.
no_review_requested_to
(
user1
))
.
to
eq
([
merge_request2
,
merge_request3
,
merge_request4
])
end
end
describe
'.drafts'
do
it
'returns MRs where draft == true'
do
expect
(
described_class
.
drafts
).
to
eq
([
merge_request4
])
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