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
Léo-Paul Géneau
gitlab-ce
Commits
084bac89
Commit
084bac89
authored
Sep 07, 2016
by
Jacob Vosmaer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Express intentions as expectations
parent
0f08bb86
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
5 deletions
+19
-5
spec/models/repository_spec.rb
spec/models/repository_spec.rb
+19
-5
No files found.
spec/models/repository_spec.rb
View file @
084bac89
...
@@ -475,7 +475,14 @@ describe Repository, models: true do
...
@@ -475,7 +475,14 @@ describe Repository, models: true do
context
'when the update adds more than one commit'
do
context
'when the update adds more than one commit'
do
it
'runs without errors'
do
it
'runs without errors'
do
old_rev
=
'33f3729a45c02fc67d00adb1b8bca394b0e761d9'
# ancestor of new_rev by more than one commit
old_rev
=
'33f3729a45c02fc67d00adb1b8bca394b0e761d9'
# old_rev is an ancestor of new_rev
expect
(
repository
.
rugged
.
merge_base
(
old_rev
,
new_rev
)).
to
eq
(
old_rev
)
# old_rev is not a direct ancestor (parent) of new_rev
expect
(
repository
.
rugged
.
lookup
(
new_rev
).
parent_ids
).
not_to
include
(
old_rev
)
branch
=
'feature-ff-target'
branch
=
'feature-ff-target'
repository
.
add_branch
(
user
,
branch
,
old_rev
)
repository
.
add_branch
(
user
,
branch
,
old_rev
)
...
@@ -485,10 +492,17 @@ describe Repository, models: true do
...
@@ -485,10 +492,17 @@ describe Repository, models: true do
context
'when the update would remove commits from the target branch'
do
context
'when the update would remove commits from the target branch'
do
it
'raises an exception'
do
it
'raises an exception'
do
# We use the fact that 'master' has diverged from 'feature' (new_rev):
branch
=
'master'
# updating 'master' to new_rev would make us lose commits, which should
old_rev
=
repository
.
find_branch
(
branch
).
target
.
sha
# not happen.
expect
{
repository
.
update_branch_with_hooks
(
user
,
'master'
)
{
new_rev
}
}.
to
raise_error
(
Repository
::
CommitError
)
# The 'master' branch is NOT an ancestor of new_rev.
expect
(
repository
.
rugged
.
merge_base
(
old_rev
,
new_rev
)).
not_to
eq
(
old_rev
)
# Updating 'master' to new_rev would lose the commits on 'master' that
# are not contained in new_rev. This should not be allowed.
expect
do
repository
.
update_branch_with_hooks
(
user
,
branch
)
{
new_rev
}
end
.
to
raise_error
(
Repository
::
CommitError
)
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