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
86f43912
Commit
86f43912
authored
Aug 28, 2017
by
Oswaldo Ferreira
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Cleans merge_jid when possible on MergeService
parent
ffc576d7
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
34 additions
and
8 deletions
+34
-8
app/services/merge_requests/merge_service.rb
app/services/merge_requests/merge_service.rb
+6
-3
spec/services/merge_requests/merge_service_spec.rb
spec/services/merge_requests/merge_service_spec.rb
+28
-5
No files found.
app/services/merge_requests/merge_service.rb
View file @
86f43912
...
...
@@ -26,14 +26,13 @@ module MergeRequests
merge_request
.
in_locked_state
do
if
commit
after_merge
clean_merge_jid
success
end
end
rescue
MergeError
=>
e
clean_merge_jid
log_merge_error
(
e
.
message
,
save_message_on_model:
true
)
ensure
# Make sure to clean up merge_jid in the end of the merge process.
merge_request
.
update_column
(
:merge_jid
,
nil
)
end
private
...
...
@@ -73,6 +72,10 @@ module MergeRequests
end
end
def
clean_merge_jid
merge_request
.
update_column
(
:merge_jid
,
nil
)
end
def
branch_deletion_user
@merge_request
.
force_remove_source_branch?
?
@merge_request
.
author
:
current_user
end
...
...
spec/services/merge_requests/merge_service_spec.rb
View file @
86f43912
...
...
@@ -12,13 +12,36 @@ describe MergeRequests::MergeService do
end
describe
'#execute'
do
it
'cleans up merge_jid from MergeRequest'
do
merge_request
.
update_column
(
:merge_jid
,
'hash-123'
)
service
=
described_class
.
new
(
project
,
user
,
commit_message:
'Awesome message'
)
context
'MergeRequest#merge_jid'
do
before
do
merge_request
.
update_column
(
:merge_jid
,
'hash-123'
)
end
it
'is cleaned when no error is raised'
do
service
=
described_class
.
new
(
project
,
user
,
commit_message:
'Awesome message'
)
service
.
execute
(
merge_request
)
expect
(
merge_request
.
reload
.
merge_jid
).
to
be_nil
end
service
.
execute
(
merge_request
)
it
'is cleaned when expected error is raised'
do
service
=
described_class
.
new
(
project
,
user
,
commit_message:
'Awesome message'
)
allow
(
service
).
to
receive
(
:commit
).
and_raise
(
described_class
::
MergeError
)
expect
(
merge_request
.
reload
.
merge_jid
).
to
be_nil
service
.
execute
(
merge_request
)
expect
(
merge_request
.
reload
.
merge_jid
).
to
be_nil
end
it
'is not cleaned when unexpected error is raised'
do
service
=
described_class
.
new
(
project
,
user
,
commit_message:
'Awesome message'
)
allow
(
service
).
to
receive
(
:commit
).
and_raise
(
StandardError
)
expect
{
service
.
execute
(
merge_request
)
}.
to
raise_error
(
StandardError
)
expect
(
merge_request
.
reload
.
merge_jid
).
to
be_present
end
end
context
'valid params'
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