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
Hide 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,65 +440,73 @@ describe Gitlab::Checks::ChangeAccess do
...
@@ -440,65 +440,73 @@ describe Gitlab::Checks::ChangeAccess do
end
end
end
end
end
end
end
context
'Check commit author rules'
do
context
'file lock rules'
do
before
do
let!
(
:path_lock
)
{
create
(
:path_lock
,
path:
'README'
,
project:
project
)
}
stub_licensed_features
(
commit_committer_check:
true
)
end
let
(
:push_rule
)
{
create
(
:push_rule
,
commit_committer_check:
true
)
}
context
'with a commit from the authenticated user'
do
before
do
before
do
allow
(
project
.
repository
).
to
receive
(
:new_commits
).
and_return
(
allow_any_instance_of
(
Commit
).
to
receive
(
:committer_email
).
and_return
(
user
.
email
)
project
.
repository
.
commits_between
(
'be93687618e4b132087f430a4d8fc3a609c9b77c'
,
'54fcc214b94e78d7a41a9a8fe6d87a5e59500e51'
)
end
)
end
it
'does not return an error'
do
it
'returns an error if the changes update a path locked by another user'
do
expect
{
subject
}.
not_to
raise_error
expect
{
subject
}.
to
raise_error
(
Gitlab
::
GitAccess
::
UnauthorizedError
,
"The path 'README' is locked by
#{
path_lock
.
user
.
name
}
"
)
end
end
end
it
'allows the commit when they were done with another email that belongs to the current user'
do
context
'Check commit author rules'
do
allow_any_instance_of
(
Commit
).
to
receive
(
:committer_email
).
and_return
(
'secondary_email@user.com'
)
before
do
user
.
emails
.
create
(
email:
'secondary_email@user.com'
,
confirmed_at:
Time
.
now
)
stub_licensed_features
(
commit_committer_check:
true
)
end
expect
{
subject
}.
not_to
raise_error
let
(
:push_rule
)
{
create
(
:push_rule
,
commit_committer_check:
true
)
}
end
let
(
:project
)
{
create
(
:project
,
:public
,
:repository
,
push_rule:
push_rule
)
}
it
'raises an error when the commit was done with an unverified email'
do
context
'with a commit from the authenticated user'
do
allow_any_instance_of
(
Commit
).
to
receive
(
:committer_email
).
and_return
(
'secondary_email@user.com'
)
before
do
user
.
emails
.
create
(
email:
'secondary_email@user.com'
)
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
)
end
expect
{
subject
}
it
'does not return an error'
do
.
to
raise_error
(
Gitlab
::
GitAccess
::
UnauthorizedError
,
expect
{
subject
}.
not_to
raise_error
"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
'allows the commit when they were done with another email that belongs to the current user'
do
before
do
user
.
emails
.
create
(
email:
'secondary_email@user.com'
,
confirmed_at:
Time
.
now
)
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
(
'secondary_email@user.com'
)
end
it
'returns an error'
do
expect
{
subject
}.
not_to
raise_error
expect
{
subject
}
.
to
raise_error
(
Gitlab
::
GitAccess
::
UnauthorizedError
,
"Committer 'some@mail.com' unknown, do you need to add that email to your profile?"
)
end
end
end
end
end
context
'file lock rules'
do
it
'raises an error when the commit was done with an unverified email'
do
let!
(
:path_lock
)
{
create
(
:path_lock
,
path:
'README'
,
project:
project
)
}
user
.
emails
.
create
(
email:
'secondary_email@user.com'
)
allow_any_instance_of
(
Commit
).
to
receive
(
:committer_email
).
and_return
(
'secondary_email@user.com'
)
before
do
expect
{
subject
}
allow
(
project
.
repository
).
to
receive
(
:new_commits
).
and_return
(
.
to
raise_error
(
Gitlab
::
GitAccess
::
UnauthorizedError
,
project
.
repository
.
commits_between
(
'be93687618e4b132087f430a4d8fc3a609c9b77c'
,
'54fcc214b94e78d7a41a9a8fe6d87a5e59500e51'
)
"Committer email 'secondary_email@user.com' not verified. Verify the email on your profile page."
)
)
end
it
'raises an error when using an unknown email'
do
allow_any_instance_of
(
Commit
).
to
receive
(
:committer_email
).
and_return
(
'some@mail.com'
)
expect
{
subject
}
.
to
raise_error
(
Gitlab
::
GitAccess
::
UnauthorizedError
,
"Committer 'some@mail.com' unknown, do you need to add that email to your profile?"
)
end
end
end
it
'returns an error if the changes update a path locked by another user'
do
context
'for an ff merge request'
do
expect
{
subject
}.
to
raise_error
(
Gitlab
::
GitAccess
::
UnauthorizedError
,
"The path 'README' is locked by
#{
path_lock
.
user
.
name
}
"
)
# the signed-commits branch fast-forwards onto master
let
(
:newrev
)
{
'2d1096e3'
}
it
'does not raise errors for a fast forward'
do
expect
{
subject
}.
not_to
raise_error
end
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