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
93c77e14
Commit
93c77e14
authored
May 27, 2021
by
Kerri Miller
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add .drafts scope to MergeRequests
Adds .drafts to offer filtering by drafts status Changelog: added
parent
399d2fe9
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
2 deletions
+11
-2
app/models/merge_request.rb
app/models/merge_request.rb
+1
-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 @
93c77e14
...
...
@@ -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
)
...
...
spec/models/merge_request_spec.rb
View file @
93c77e14
...
...
@@ -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