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
888c1a3f
Commit
888c1a3f
authored
Oct 16, 2015
by
Stan Hu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add spec for refresh service adding notes to restored branches
parent
bf290a52
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
17 additions
and
16 deletions
+17
-16
app/services/merge_requests/refresh_service.rb
app/services/merge_requests/refresh_service.rb
+2
-3
spec/services/merge_requests/refresh_service_spec.rb
spec/services/merge_requests/refresh_service_spec.rb
+13
-11
spec/services/system_note_service_spec.rb
spec/services/system_note_service_spec.rb
+2
-2
No files found.
app/services/merge_requests/refresh_service.rb
View file @
888c1a3f
...
...
@@ -90,9 +90,8 @@ module MergeRequests
# Since any number of commits could have been made to the restored branch,
# find the common root to see what has been added.
common_ref
=
@project
.
repository
.
merge_base
(
last_commit
.
id
,
@newrev
)
# If the last_commit no longer exists in this new branch,
# gitlab_git throws a Rugged::OdbError
# This is fixed in https://gitlab.com/gitlab-org/gitlab_git/merge_requests/52
# If the a commit no longer exists in this repo, gitlab_git throws
# a Rugged::OdbError. This is fixed in https://gitlab.com/gitlab-org/gitlab_git/merge_requests/52
@commits
=
@project
.
repository
.
commits_between
(
common_ref
,
@newrev
)
if
common_ref
rescue
end
...
...
spec/services/merge_requests/refresh_service_spec.rb
View file @
888c1a3f
...
...
@@ -108,21 +108,23 @@ describe MergeRequests::RefreshService do
context
'push new branch that exists in a merge request'
do
let
(
:refresh_service
)
{
service
.
new
(
@fork_project
,
@user
)
}
before
do
allow
(
refresh_service
).
to
receive
(
:execute_hooks
)
it
'refreshes the merge request'
do
expect
(
refresh_service
).
to
receive
(
:execute_hooks
).
with
(
@fork_merge_request
,
'update'
)
allow_any_instance_of
(
Repository
).
to
receive
(
:merge_base
).
and_return
(
@oldrev
)
refresh_service
.
execute
(
Gitlab
::
Git
::
BLANK_SHA
,
@newrev
,
'refs/heads/master'
)
reload_mrs
end
it
'should execute hooks with update action'
do
expect
(
refresh_service
).
to
have_received
(
:execute_hooks
).
with
(
@fork_merge_request
,
'update'
)
end
expect
(
@merge_request
.
notes
).
to
be_empty
expect
(
@merge_request
).
to
be_open
it
{
expect
(
@merge_request
.
notes
).
to
be_empty
}
it
{
expect
(
@merge_request
).
to
be_open
}
it
{
expect
(
@fork_merge_request
.
notes
.
last
.
note
).
to
include
(
'Source branch `master` restored'
)
}
it
{
expect
(
@fork_merge_request
).
to
be_open
}
notes
=
@fork_merge_request
.
notes
.
reorder
(
:created_at
).
map
(
&
:note
)
expect
(
notes
[
0
]).
to
include
(
'Source branch `master` restored'
)
expect
(
notes
[
1
]).
to
include
(
'Added 4 commits'
)
expect
(
@fork_merge_request
).
to
be_open
end
end
def
reload_mrs
...
...
spec/services/system_note_service_spec.rb
View file @
888c1a3f
...
...
@@ -229,7 +229,7 @@ describe SystemNoteService do
end
describe
'.change_branch'
do
subject
{
described_class
.
change_branch
(
noteable
,
project
,
author
,
:target
,
old_branch
,
new_branch
)
}
subject
{
described_class
.
change_branch
(
noteable
,
project
,
author
,
'target'
,
old_branch
,
new_branch
)
}
let
(
:old_branch
)
{
'old_branch'
}
let
(
:new_branch
)
{
'new_branch'
}
...
...
@@ -243,7 +243,7 @@ describe SystemNoteService do
end
describe
'.change_branch_presence'
do
subject
{
described_class
.
change_branch_presence
(
noteable
,
project
,
author
,
'source'
,
'feature'
,
:delete
)
}
subject
{
described_class
.
change_branch_presence
(
noteable
,
project
,
author
,
:source
,
'feature'
,
:delete
)
}
it_behaves_like
'a system note'
...
...
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