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
f436f3e6
Commit
f436f3e6
authored
Nov 01, 2017
by
Bob Van Landuyt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add a spec for a fast forward merge
parent
c5159a49
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
52 additions
and
44 deletions
+52
-44
spec/lib/gitlab/checks/change_access_spec.rb
spec/lib/gitlab/checks/change_access_spec.rb
+52
-44
No files found.
spec/lib/gitlab/checks/change_access_spec.rb
View file @
f436f3e6
...
@@ -440,6 +440,21 @@ describe Gitlab::Checks::ChangeAccess do
...
@@ -440,6 +440,21 @@ describe Gitlab::Checks::ChangeAccess do
end
end
end
end
end
end
end
context
'file lock rules'
do
let!
(
:path_lock
)
{
create
(
:path_lock
,
path:
'README'
,
project:
project
)
}
before
do
allow
(
project
.
repository
).
to
receive
(
:new_commits
).
and_return
(
project
.
repository
.
commits_between
(
'be93687618e4b132087f430a4d8fc3a609c9b77c'
,
'54fcc214b94e78d7a41a9a8fe6d87a5e59500e51'
)
)
end
it
'returns an error if the changes update a path locked by another user'
do
expect
{
subject
}.
to
raise_error
(
Gitlab
::
GitAccess
::
UnauthorizedError
,
"The path 'README' is locked by
#{
path_lock
.
user
.
name
}
"
)
end
end
context
'Check commit author rules'
do
context
'Check commit author rules'
do
before
do
before
do
...
@@ -447,9 +462,13 @@ describe Gitlab::Checks::ChangeAccess do
...
@@ -447,9 +462,13 @@ describe Gitlab::Checks::ChangeAccess do
end
end
let
(
:push_rule
)
{
create
(
:push_rule
,
commit_committer_check:
true
)
}
let
(
:push_rule
)
{
create
(
:push_rule
,
commit_committer_check:
true
)
}
let
(
:project
)
{
create
(
:project
,
:public
,
:repository
,
push_rule:
push_rule
)
}
context
'with a commit from the authenticated user'
do
context
'with a commit from the authenticated user'
do
before
do
before
do
allow
(
project
.
repository
).
to
receive
(
:new_commits
).
and_return
(
project
.
repository
.
commits_between
(
'be93687618e4b132087f430a4d8fc3a609c9b77c'
,
'54fcc214b94e78d7a41a9a8fe6d87a5e59500e51'
)
)
allow_any_instance_of
(
Commit
).
to
receive
(
:committer_email
).
and_return
(
user
.
email
)
allow_any_instance_of
(
Commit
).
to
receive
(
:committer_email
).
and_return
(
user
.
email
)
end
end
...
@@ -458,47 +477,36 @@ describe Gitlab::Checks::ChangeAccess do
...
@@ -458,47 +477,36 @@ describe Gitlab::Checks::ChangeAccess do
end
end
it
'allows the commit when they were done with another email that belongs to the current user'
do
it
'allows the commit when they were done with another email that belongs to the current user'
do
allow_any_instance_of
(
Commit
).
to
receive
(
:committer_email
).
and_return
(
'secondary_email@user.com'
)
user
.
emails
.
create
(
email:
'secondary_email@user.com'
,
confirmed_at:
Time
.
now
)
user
.
emails
.
create
(
email:
'secondary_email@user.com'
,
confirmed_at:
Time
.
now
)
allow_any_instance_of
(
Commit
).
to
receive
(
:committer_email
).
and_return
(
'secondary_email@user.com'
)
expect
{
subject
}.
not_to
raise_error
expect
{
subject
}.
not_to
raise_error
end
end
it
'raises an error when the commit was done with an unverified email'
do
it
'raises an error when the commit was done with an unverified email'
do
allow_any_instance_of
(
Commit
).
to
receive
(
:committer_email
).
and_return
(
'secondary_email@user.com'
)
user
.
emails
.
create
(
email:
'secondary_email@user.com'
)
user
.
emails
.
create
(
email:
'secondary_email@user.com'
)
allow_any_instance_of
(
Commit
).
to
receive
(
:committer_email
).
and_return
(
'secondary_email@user.com'
)
expect
{
subject
}
expect
{
subject
}
.
to
raise_error
(
Gitlab
::
GitAccess
::
UnauthorizedError
,
.
to
raise_error
(
Gitlab
::
GitAccess
::
UnauthorizedError
,
"Committer email 'secondary_email@user.com' not verified. Verify the email on your profile page."
)
"Committer email 'secondary_email@user.com' not verified. Verify the email on your profile page."
)
end
end
end
context
'with a commit using an unknown e-mail'
do
it
'raises an error when using an unknown email'
do
before
do
allow_any_instance_of
(
Commit
).
to
receive
(
:committer_email
).
and_return
(
'some@mail.com'
)
allow_any_instance_of
(
Commit
).
to
receive
(
:committer_email
).
and_return
(
'some@mail.com'
)
end
it
'returns an error'
do
expect
{
subject
}
expect
{
subject
}
.
to
raise_error
(
Gitlab
::
GitAccess
::
UnauthorizedError
,
.
to
raise_error
(
Gitlab
::
GitAccess
::
UnauthorizedError
,
"Committer 'some@mail.com' unknown, do you need to add that email to your profile?"
)
"Committer 'some@mail.com' unknown, do you need to add that email to your profile?"
)
end
end
end
end
end
end
context
'file lock rules'
do
context
'for an ff merge request'
do
let!
(
:path_lock
)
{
create
(
:path_lock
,
path:
'README'
,
project:
project
)
}
# the signed-commits branch fast-forwards onto master
let
(
:newrev
)
{
'2d1096e3'
}
before
do
it
'does not raise errors for a fast forward'
do
allow
(
project
.
repository
).
to
receive
(
:new_commits
).
and_return
(
expect
{
subject
}.
not_to
raise_error
project
.
repository
.
commits_between
(
'be93687618e4b132087f430a4d8fc3a609c9b77c'
,
'54fcc214b94e78d7a41a9a8fe6d87a5e59500e51'
)
)
end
end
it
'returns an error if the changes update a path locked by another user'
do
expect
{
subject
}.
to
raise_error
(
Gitlab
::
GitAccess
::
UnauthorizedError
,
"The path 'README' is locked by
#{
path_lock
.
user
.
name
}
"
)
end
end
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