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
289a6100
Commit
289a6100
authored
May 02, 2018
by
Michael Kozono
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Dry up tests
parent
b8a031e5
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
35 additions
and
43 deletions
+35
-43
qa/qa/specs/features/repository/protected_branches_spec.rb
qa/qa/specs/features/repository/protected_branches_spec.rb
+35
-43
No files found.
qa/qa/specs/features/repository/protected_branches_spec.rb
View file @
289a6100
...
@@ -27,69 +27,61 @@ module QA
...
@@ -27,69 +27,61 @@ module QA
end
end
scenario
'user is able to protect a branch'
do
scenario
'user is able to protect a branch'
do
protected_branch
=
Factory
::
Resource
::
Branch
.
fabricate!
do
|
resource
|
protected_branch
=
fabricate_branch
(
allow_to_push:
true
)
resource
.
branch_name
=
branch_name
resource
.
project
=
project
resource
.
allow_to_push
=
true
resource
.
protected
=
true
end
expect
(
protected_branch
.
name
).
to
have_content
(
branch_name
)
expect
(
protected_branch
.
name
).
to
have_content
(
branch_name
)
expect
(
protected_branch
.
push_allowance
).
to
have_content
(
'Developers + Maintainers'
)
expect
(
protected_branch
.
push_allowance
).
to
have_content
(
'Developers + Maintainers'
)
end
end
scenario
'users without authorization cannot push to protected branch'
do
context
'push to protected branch'
do
Factory
::
Resource
::
Branch
.
fabricate!
do
|
resource
|
scenario
'unauthorized users are blocked'
do
resource
.
branch_name
=
branch_name
fabricate_branch
(
allow_to_push:
false
)
resource
.
project
=
project
resource
.
allow_to_push
=
false
resource
.
protected
=
true
end
project
.
visit!
project
.
visit!
Git
::
Repository
.
perform
do
|
repository
|
Git
::
Repository
.
perform
do
|
repository
|
repository
.
uri
=
location
.
uri
push_output
=
push_to_repository
(
repository
)
repository
.
use_default_credentials
repository
.
act
do
expect
(
push_output
)
clone
.
to
match
(
/remote\: GitLab\: You are not allowed to push code to protected branches on this project/
)
configure_identity
(
'GitLab QA'
,
'root@gitlab.com'
)
expect
(
push_output
)
checkout
(
'protected-branch'
)
.
to
match
(
/\[remote rejected\]
#{
branch_name
}
->
#{
branch_name
}
\(pre-receive hook declined\)/
)
commit_file
(
'README.md'
,
'readme content'
,
'Add a readme'
)
push_changes
(
'protected-branch'
)
end
end
end
scenario
'authorized users are allowed'
do
fabricate_branch
(
allow_to_push:
true
)
project
.
visit!
expect
(
repository
.
push_output
)
Git
::
Repository
.
perform
do
|
repository
|
.
to
match
(
/remote\: GitLab\: You are not allowed to push code to protected branches on this project/
)
push_output
=
push_to_repository
(
repository
)
expect
(
repository
.
push_output
)
.
to
match
(
/\[remote rejected\]
#{
branch_name
}
->
#{
branch_name
}
\(pre-receive hook declined\)/
)
expect
(
push_output
).
to
match
(
/remote: To create a merge request for protected-branch, visit/
)
end
end
end
end
end
scenario
'users with authorization can push to protected branch'
do
def
fabricate_branch
(
allow_to_push
:)
Factory
::
Resource
::
Branch
.
fabricate!
do
|
resource
|
Factory
::
Resource
::
Branch
.
fabricate!
do
|
resource
|
resource
.
branch_name
=
branch_name
resource
.
branch_name
=
branch_name
resource
.
project
=
project
resource
.
project
=
project
resource
.
allow_to_push
=
true
resource
.
allow_to_push
=
allow_to_push
resource
.
protected
=
true
resource
.
protected
=
true
end
end
end
project
.
visit!
def
push_to_repository
(
repository
)
repository
.
uri
=
location
.
uri
Git
::
Repository
.
perform
do
|
repository
|
repository
.
use_default_credentials
repository
.
uri
=
location
.
uri
repository
.
use_default_credentials
repository
.
act
do
clone
configure_identity
(
'GitLab QA'
,
'root@gitlab.com'
)
checkout
(
'protected-branch'
)
commit_file
(
'README.md'
,
'readme content'
,
'Add a readme'
)
push_changes
(
'protected-branch'
)
end
expect
(
repository
.
push_output
).
to
match
(
/remote: To create a merge request for protected-branch, visit/
)
repository
.
act
do
clone
configure_identity
(
'GitLab QA'
,
'root@gitlab.com'
)
checkout
(
'protected-branch'
)
commit_file
(
'README.md'
,
'readme content'
,
'Add a readme'
)
push_changes
(
'protected-branch'
)
push_output
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