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
0
Merge Requests
0
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
Boxiang Sun
gitlab-ce
Commits
dd35c1d5
Commit
dd35c1d5
authored
Sep 14, 2017
by
Valery Sizov
Committed by
Eric Eastwood
Sep 19, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add spec for FfMergeService
parent
7af585f1
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
84 additions
and
1 deletion
+84
-1
app/models/project.rb
app/models/project.rb
+0
-1
spec/services/merge_requests/ff_merge_service_spec.rb
spec/services/merge_requests/ff_merge_service_spec.rb
+84
-0
No files found.
app/models/project.rb
View file @
dd35c1d5
...
...
@@ -1572,7 +1572,6 @@ class Project < ActiveRecord::Base
def
ff_merge_must_be_possible?
self
.
merge_requests_ff_only_enabled
end
# alias_method :merge_requests_ff_only_enabled?, :merge_requests_ff_only_enabled
private
...
...
spec/services/merge_requests/ff_merge_service_spec.rb
0 → 100644
View file @
dd35c1d5
require
'spec_helper'
describe
MergeRequests
::
FfMergeService
do
let
(
:user
)
{
create
(
:user
)
}
let
(
:user2
)
{
create
(
:user
)
}
let
(
:merge_request
)
do
create
(
:merge_request
,
source_branch:
'flatten-dir'
,
target_branch:
'improve/awesome'
,
assignee:
user2
)
end
let
(
:project
)
{
merge_request
.
project
}
before
do
project
.
team
<<
[
user
,
:master
]
project
.
team
<<
[
user2
,
:developer
]
end
describe
'#execute'
do
context
'valid params'
do
let
(
:service
)
{
described_class
.
new
(
project
,
user
,
{})
}
before
do
allow
(
service
).
to
receive
(
:execute_hooks
)
perform_enqueued_jobs
do
service
.
execute
(
merge_request
)
end
end
it
"does not create merge commit"
do
source_branch_sha
=
merge_request
.
source_project
.
repository
.
commit
(
merge_request
.
source_branch
).
sha
target_branch_sha
=
merge_request
.
target_project
.
repository
.
commit
(
merge_request
.
target_branch
).
sha
expect
(
source_branch_sha
).
to
eq
(
target_branch_sha
)
end
it
{
expect
(
merge_request
).
to
be_valid
}
it
{
expect
(
merge_request
).
to
be_merged
}
it
'sends email to user2 about merge of new merge_request'
do
email
=
ActionMailer
::
Base
.
deliveries
.
last
expect
(
email
.
to
.
first
).
to
eq
(
user2
.
email
)
expect
(
email
.
subject
).
to
include
(
merge_request
.
title
)
end
it
'creates system note about merge_request merge'
do
note
=
merge_request
.
notes
.
last
expect
(
note
.
note
).
to
include
'merged'
end
end
context
"error handling"
do
let
(
:service
)
{
described_class
.
new
(
project
,
user
,
commit_message:
'Awesome message'
)
}
before
do
allow
(
Rails
.
logger
).
to
receive
(
:error
)
end
it
'logs and saves error if there is an exception'
do
error_message
=
'error message'
allow
(
service
).
to
receive
(
:repository
).
and_raise
(
"error message"
)
allow
(
service
).
to
receive
(
:execute_hooks
)
service
.
execute
(
merge_request
)
expect
(
merge_request
.
merge_error
).
to
include
(
error_message
)
expect
(
Rails
.
logger
).
to
have_received
(
:error
).
with
(
a_string_matching
(
error_message
))
end
it
'logs and saves error if there is an PreReceiveError exception'
do
error_message
=
'error message'
allow
(
service
).
to
receive
(
:repository
).
and_raise
(
Gitlab
::
Git
::
HooksService
::
PreReceiveError
,
error_message
)
allow
(
service
).
to
receive
(
:execute_hooks
)
service
.
execute
(
merge_request
)
expect
(
merge_request
.
merge_error
).
to
include
(
error_message
)
expect
(
Rails
.
logger
).
to
have_received
(
:error
).
with
(
a_string_matching
(
error_message
))
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