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
13aa6f67
Commit
13aa6f67
authored
May 24, 2018
by
Mark Chao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add spec
parent
b1ab1609
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
34 additions
and
22 deletions
+34
-22
spec/models/merge_request_spec.rb
spec/models/merge_request_spec.rb
+34
-22
No files found.
spec/models/merge_request_spec.rb
View file @
13aa6f67
...
@@ -1245,38 +1245,50 @@ describe MergeRequest do
...
@@ -1245,38 +1245,50 @@ describe MergeRequest do
describe
'#check_if_can_be_merged'
do
describe
'#check_if_can_be_merged'
do
let
(
:project
)
{
create
(
:project
,
only_allow_merge_if_pipeline_succeeds:
true
)
}
let
(
:project
)
{
create
(
:project
,
only_allow_merge_if_pipeline_succeeds:
true
)
}
subject
{
create
(
:merge_request
,
source_project:
project
,
merge_status: :unchecked
)
}
shared_examples
'checking if can be merged'
do
context
'when it is not broken and has no conflicts'
do
before
do
allow
(
subject
).
to
receive
(
:broken?
)
{
false
}
allow
(
project
.
repository
).
to
receive
(
:can_be_merged?
).
and_return
(
true
)
end
context
'when it is not broken and has no conflicts'
do
it
'is marked as mergeable'
do
before
do
expect
{
subject
.
check_if_can_be_merged
}.
to
change
{
subject
.
merge_status
}.
to
(
'can_be_merged'
)
allow
(
subject
).
to
receive
(
:broken?
)
{
false
}
end
allow
(
project
.
repository
).
to
receive
(
:can_be_merged?
).
and_return
(
true
)
end
end
it
'is marked as mergeable
'
do
context
'when broken
'
do
expect
{
subject
.
check_if_can_be_merged
}.
to
change
{
subject
.
merge_status
}.
to
(
'can_be_merged'
)
before
do
end
allow
(
subject
).
to
receive
(
:broken?
)
{
true
}
end
end
context
'when broken
'
do
it
'becomes unmergeable
'
do
before
do
expect
{
subject
.
check_if_can_be_merged
}.
to
change
{
subject
.
merge_status
}.
to
(
'cannot_be_merged'
)
allow
(
subject
).
to
receive
(
:broken?
)
{
true
}
end
end
end
it
'becomes unmergeable'
do
context
'when it has conflicts'
do
expect
{
subject
.
check_if_can_be_merged
}.
to
change
{
subject
.
merge_status
}.
to
(
'cannot_be_merged'
)
before
do
allow
(
subject
).
to
receive
(
:broken?
)
{
false
}
allow
(
project
.
repository
).
to
receive
(
:can_be_merged?
).
and_return
(
false
)
end
it
'becomes unmergeable'
do
expect
{
subject
.
check_if_can_be_merged
}.
to
change
{
subject
.
merge_status
}.
to
(
'cannot_be_merged'
)
end
end
end
end
end
context
'when it has conflicts'
do
context
'when merge_status is unchecked'
do
before
do
subject
{
create
(
:merge_request
,
source_project:
project
,
merge_status: :unchecked
)
}
allow
(
subject
).
to
receive
(
:broken?
)
{
false
}
allow
(
project
.
repository
).
to
receive
(
:can_be_merged?
).
and_return
(
false
)
end
it
'becomes unmergeable'
do
it_behaves_like
'checking if can be merged'
expect
{
subject
.
check_if_can_be_merged
}.
to
change
{
subject
.
merge_status
}.
to
(
'cannot_be_merged'
)
end
end
context
'when merge_status is unchecked'
do
subject
{
create
(
:merge_request
,
source_project:
project
,
merge_status: :cannot_be_merged_recheck
)
}
it_behaves_like
'checking if can be merged'
end
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