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
6ba39cea
Commit
6ba39cea
authored
Oct 23, 2020
by
Kev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add simple test for reverting_merge_request
parent
13a2352c
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
58 additions
and
0 deletions
+58
-0
spec/models/merge_request_spec.rb
spec/models/merge_request_spec.rb
+58
-0
No files found.
spec/models/merge_request_spec.rb
View file @
6ba39cea
...
...
@@ -2413,6 +2413,64 @@ RSpec.describe MergeRequest, factory_default: :keep do
end
end
describe
'#reverting_merge_request'
do
subject
{
create
(
:merge_request
,
source_project:
create
(
:project
,
:repository
))
}
context
'when there is no merge_commit for the MR'
do
before
do
subject
.
metrics
.
update!
(
merged_at:
Time
.
current
.
utc
)
end
it
'returns nil'
do
expect
(
subject
.
reverting_merge_request
(
nil
)).
to
be_nil
end
end
context
'when the MR has been merged'
do
before
do
MergeRequests
::
MergeService
.
new
(
subject
.
target_project
,
subject
.
author
,
{
sha:
subject
.
diff_head_sha
})
.
execute
(
subject
)
end
context
'when there is no revert commit'
do
it
'returns nil'
do
expect
(
subject
.
reverting_merge_request
(
nil
)).
to
be_nil
end
end
context
'when there is no merged_at for the MR'
do
before
do
subject
.
metrics
.
update!
(
merged_at:
nil
)
end
it
'returns nil'
do
expect
(
subject
.
reverting_merge_request
(
nil
)).
to
be_nil
end
end
context
'when there is a revert commit by MR'
do
let
(
:current_user
)
{
subject
.
author
}
let
(
:branch
)
{
subject
.
target_branch
}
let
(
:project
)
{
subject
.
target_project
}
let
(
:revert_commit_id
)
do
params
=
{
commit:
subject
.
merge_commit
,
branch_name:
branch
,
start_branch:
branch
}
Commits
::
RevertService
.
new
(
project
,
current_user
,
params
).
execute
[
:result
]
end
it
'returns nil'
do
expect
(
subject
.
reverting_merge_request
(
current_user
)).
to
be_nil
end
end
end
end
describe
'#can_be_reverted?'
do
subject
{
create
(
:merge_request
,
source_project:
create
(
:project
,
:repository
))
}
...
...
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