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
745ece3f
Commit
745ece3f
authored
May 25, 2021
by
Kerri Miller
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Set draft status field before saving MR
Set draft status (true/false) based on parsing the title.
parent
141a7cd2
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
38 additions
and
0 deletions
+38
-0
app/models/merge_request.rb
app/models/merge_request.rb
+6
-0
spec/models/merge_request_spec.rb
spec/models/merge_request_spec.rb
+32
-0
No files found.
app/models/merge_request.rb
View file @
745ece3f
...
...
@@ -125,6 +125,8 @@ class MergeRequest < ApplicationRecord
].
freeze
serialize
:merge_params
,
Hash
# rubocop:disable Cop/ActiveRecordSerialize
before_validation
:set_draft_status
after_create
:ensure_merge_request_diff
after_update
:clear_memoized_shas
after_update
:reload_diff_if_branch_changed
...
...
@@ -1908,6 +1910,10 @@ class MergeRequest < ApplicationRecord
private
def
set_draft_status
self
.
draft
=
draft?
end
def
missing_report_error
(
report_type
)
{
status: :error
,
status_reason:
"This merge request does not have
#{
report_type
}
reports"
}
end
...
...
spec/models/merge_request_spec.rb
View file @
745ece3f
...
...
@@ -317,6 +317,38 @@ RSpec.describe MergeRequest, factory_default: :keep do
expect
(
merge_request
.
target_project_id
).
to
eq
(
merge_request
.
metrics
.
target_project_id
)
end
end
describe
'#set_draft_status'
do
let
(
:merge_request
)
{
create
(
:merge_request
)
}
context
'MR is a draft'
do
before
do
expect
(
merge_request
.
draft
).
to
be_falsy
merge_request
.
title
=
"Draft:
#{
merge_request
.
title
}
"
end
it
'sets draft to true'
do
merge_request
.
save!
expect
(
merge_request
.
draft
).
to
be_truthy
end
end
context
'MR is not a draft'
do
before
do
expect
(
merge_request
.
draft
).
to
be_falsey
merge_request
.
title
=
"This is not a draft"
end
it
'sets draft to true'
do
merge_request
.
save!
expect
(
merge_request
.
draft
).
to
be_falsey
end
end
end
end
describe
'respond to'
do
...
...
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