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
57505bfe
Commit
57505bfe
authored
Sep 07, 2015
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Write tests for ff-merge and rebase services
parent
72e536b5
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
89 additions
and
8 deletions
+89
-8
app/services/merge_requests/rebase_service.rb
app/services/merge_requests/rebase_service.rb
+3
-0
features/project/ff_merge_requests.feature
features/project/ff_merge_requests.feature
+2
-0
features/steps/project/ff_merge_requests.rb
features/steps/project/ff_merge_requests.rb
+4
-8
spec/services/merge_requests/ff_merge_service_spec.rb
spec/services/merge_requests/ff_merge_service_spec.rb
+49
-0
spec/services/merge_requests/rebase_service_spec.rb
spec/services/merge_requests/rebase_service_spec.rb
+31
-0
No files found.
app/services/merge_requests/rebase_service.rb
View file @
57505bfe
...
@@ -51,6 +51,9 @@ module MergeRequests
...
@@ -51,6 +51,9 @@ module MergeRequests
end
end
true
true
rescue
=>
ex
log
(
'Failed to rebase branch:'
)
log
(
ex
.
message
)
ensure
ensure
clean_dir
clean_dir
Gitlab
::
ShellEnv
.
reset_env
Gitlab
::
ShellEnv
.
reset_env
...
...
features/project/ff_merge_requests.feature
View file @
57505bfe
...
@@ -15,6 +15,8 @@ Feature: Project Ff Merge Requests
...
@@ -15,6 +15,8 @@ Feature: Project Ff Merge Requests
Given
rebase before merge enabled
Given
rebase before merge enabled
When
I visit merge request page
"Bug NS-05"
When
I visit merge request page
"Bug NS-05"
Then
I should see rebase button
Then
I should see rebase button
When
I press rebase button
Then
I should see rebase in progress message
Scenario
:
I
should do rebase before ff-only merge
Scenario
:
I
should do rebase before ff-only merge
When
I visit merge request page
"Bug NS-05"
When
I visit merge request page
"Bug NS-05"
...
...
features/steps/project/ff_merge_requests.rb
View file @
57505bfe
...
@@ -72,16 +72,12 @@ class Spinach::Features::ProjectFfMergeRequests < Spinach::FeatureSteps
...
@@ -72,16 +72,12 @@ class Spinach::Features::ProjectFfMergeRequests < Spinach::FeatureSteps
project
.
save!
project
.
save!
end
end
step
'I
click on "Email Patches"
'
do
step
'I
press rebase button
'
do
click_
link
"Email Patches
"
click_
button
"Rebase
"
end
end
step
'I click on "Plain Diff"'
do
step
"I should see rebase in progress message"
do
click_link
"Plain Diff"
expect
(
page
).
to
have_content
(
"Rebase started. It will take some time"
)
end
step
'I should see a patch diff'
do
expect
(
page
).
to
have_content
(
'diff --git'
)
end
end
def
merge_request
def
merge_request
...
...
spec/services/merge_requests/ff_merge_service_spec.rb
0 → 100644
View file @
57505bfe
require
'spec_helper'
describe
MergeRequests
::
FfMergeService
do
let
(
:user
)
{
create
(
:user
)
}
let
(
:user2
)
{
create
(
:user
)
}
let
(
:merge_request
)
{
create
(
:merge_request
,
source_branch:
'flatten-dir'
,
target_branch:
'improve/awesome'
,
assignee:
user2
)
}
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
)
{
MergeRequests
::
FfMergeService
.
new
(
project
,
user
,
{})
}
before
do
allow
(
service
).
to
receive
(
:execute_hooks
)
service
.
execute
(
merge_request
)
end
it
"should 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
'should send 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
'should create system note about merge_request merge'
do
note
=
merge_request
.
notes
.
last
expect
(
note
.
note
).
to
include
'Status changed to merged'
end
end
end
end
spec/services/merge_requests/rebase_service_spec.rb
0 → 100644
View file @
57505bfe
require
'spec_helper'
describe
MergeRequests
::
RebaseService
do
let
(
:user
)
{
create
(
:user
)
}
let
(
:merge_request
)
{
create
(
:merge_request
,
source_branch:
'feature_conflict'
,
target_branch:
'master'
)}
let
(
:project
)
{
merge_request
.
project
}
before
do
project
.
team
<<
[
user
,
:master
]
end
describe
:execute
do
context
'valid params'
do
let
(
:service
)
{
MergeRequests
::
RebaseService
.
new
(
project
,
user
,
{})
}
before
do
service
.
execute
(
merge_request
)
end
it
"should rebase source branch"
do
parent_sha
=
merge_request
.
source_project
.
repository
.
commit
(
merge_request
.
source_branch
).
parents
.
first
.
sha
target_branch_sha
=
merge_request
.
target_project
.
repository
.
commit
(
merge_request
.
target_branch
).
sha
expect
(
parent_sha
).
to
eq
(
target_branch_sha
)
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