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
11996ccc
Commit
11996ccc
authored
Jun 13, 2017
by
James Edwards-Jones
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Cleaned up helper methods in protected tags/branches specs
parent
9199449f
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
36 additions
and
60 deletions
+36
-60
spec/support/protected_tags/access_control_ee_spec.rb
spec/support/protected_tags/access_control_ee_spec.rb
+16
-28
spec/support/shared_examples/features/protected_branches_access_control_ee_spec.rb
...les/features/protected_branches_access_control_ee_spec.rb
+20
-32
No files found.
spec/support/protected_tags/access_control_ee_spec.rb
View file @
11996ccc
...
...
@@ -8,20 +8,8 @@ RSpec.shared_examples "protected tags > access control > EE" do
groups
.
each
{
|
group
|
project
.
project_group_links
.
create
(
group:
group
,
group_access:
Gitlab
::
Access
::
DEVELOPER
)
}
end
def
access_type_ids
ProtectedTag
.
last
.
create_access_levels
end
def
access_levels
access_type_ids
.
map
(
&
:access_level
)
end
def
user_ids
access_type_ids
.
map
(
&
:user_id
)
end
def
group_ids
access_type_ids
.
map
(
&
:group_id
)
ProtectedTag
.
last
.
create_access_levels
end
it
"allows creating protected tags that roles, users, and groups can create"
do
...
...
@@ -37,9 +25,9 @@ RSpec.shared_examples "protected tags > access control > EE" do
within
(
".protected-tags-list"
)
{
expect
(
page
).
to
have_content
(
'v1.0'
)
}
expect
(
ProtectedTag
.
count
).
to
eq
(
1
)
roles
.
each
{
|
(
access_type_id
,
_
)
|
expect
(
access_levels
).
to
include
(
access_type_id
)
}
users
.
each
{
|
user
|
expect
(
user_ids
).
to
include
(
user
.
id
)
}
groups
.
each
{
|
group
|
expect
(
group_ids
).
to
include
(
group
.
id
)
}
roles
.
each
{
|
(
access_type_id
,
_
)
|
expect
(
access_levels
.
map
(
&
:access_level
)
).
to
include
(
access_type_id
)
}
users
.
each
{
|
user
|
expect
(
access_levels
.
map
(
&
:user_id
)
).
to
include
(
user
.
id
)
}
groups
.
each
{
|
group
|
expect
(
access_levels
.
map
(
&
:group_id
)
).
to
include
(
group
.
id
)
}
end
it
"allows updating protected tags so that roles and users can create it"
do
...
...
@@ -58,9 +46,9 @@ RSpec.shared_examples "protected tags > access control > EE" do
expect
(
ProtectedTag
.
count
).
to
eq
(
1
)
roles
.
each
{
|
(
access_type_id
,
_
)
|
expect
(
access_levels
).
to
include
(
access_type_id
)
}
users
.
each
{
|
user
|
expect
(
user_ids
).
to
include
(
user
.
id
)
}
groups
.
each
{
|
group
|
expect
(
group_ids
).
to
include
(
group
.
id
)
}
roles
.
each
{
|
(
access_type_id
,
_
)
|
expect
(
access_levels
.
map
(
&
:access_level
)
).
to
include
(
access_type_id
)
}
users
.
each
{
|
user
|
expect
(
access_levels
.
map
(
&
:user_id
)
).
to
include
(
user
.
id
)
}
groups
.
each
{
|
group
|
expect
(
access_levels
.
map
(
&
:group_id
)
).
to
include
(
group
.
id
)
}
end
it
"allows updating protected tags so that roles and users cannot create it"
do
...
...
@@ -81,7 +69,7 @@ RSpec.shared_examples "protected tags > access control > EE" do
wait_for_requests
expect
(
ProtectedTag
.
count
).
to
eq
(
1
)
expect
(
access_
type_id
s
).
to
be_empty
expect
(
access_
level
s
).
to
be_empty
end
it
"prepends selected users that can create"
do
...
...
@@ -120,8 +108,8 @@ RSpec.shared_examples "protected tags > access control > EE" do
expect
(
page
).
to
have_selector
'.dropdown-content .is-active'
,
text:
users
.
last
.
name
expect
(
ProtectedTag
.
count
).
to
eq
(
1
)
roles
.
each
{
|
(
access_type_id
,
_
)
|
expect
(
access_levels
).
to
include
(
access_type_id
)
}
expect
(
user_ids
).
to
include
(
users
.
last
.
id
)
roles
.
each
{
|
(
access_type_id
,
_
)
|
expect
(
access_levels
.
map
(
&
:access_level
)
).
to
include
(
access_type_id
)
}
expect
(
access_levels
.
map
(
&
:user_id
)
).
to
include
(
users
.
last
.
id
)
end
context
'When updating a protected tag'
do
...
...
@@ -136,20 +124,20 @@ RSpec.shared_examples "protected tags > access control > EE" do
wait_for_requests
roles
.
each
do
|
(
access_type_id
,
_
)
|
expect
(
access_levels
).
to
include
(
access_type_id
)
expect
(
access_levels
.
map
(
&
:access_level
)
).
to
include
(
access_type_id
)
end
expect
(
access_levels
).
not_to
include
(
0
)
expect
(
access_levels
.
map
(
&
:access_level
)
).
not_to
include
(
0
)
set_allowed_to
(
'create'
,
'No one'
,
form:
'.js-protected-tag-edit-form'
)
wait_for_requests
roles
.
each
do
|
(
access_type_id
,
_
)
|
expect
(
access_levels
).
not_to
include
(
access_type_id
)
expect
(
access_levels
.
map
(
&
:access_level
)
).
not_to
include
(
access_type_id
)
end
expect
(
access_levels
).
to
include
(
0
)
expect
(
access_levels
.
map
(
&
:access_level
)
).
to
include
(
0
)
end
end
...
...
@@ -165,10 +153,10 @@ RSpec.shared_examples "protected tags > access control > EE" do
wait_for_requests
roles
.
each
do
|
(
access_type_id
,
_
)
|
expect
(
access_levels
).
not_to
include
(
access_type_id
)
expect
(
access_levels
.
map
(
&
:access_level
)
).
not_to
include
(
access_type_id
)
end
expect
(
access_levels
).
to
include
(
0
)
expect
(
access_levels
.
map
(
&
:access_level
)
).
to
include
(
0
)
end
end
end
spec/support/shared_examples/features/protected_branches_access_control_ee_spec.rb
View file @
11996ccc
...
...
@@ -12,22 +12,10 @@ shared_examples "protected branches > access control > EE" do
groups
.
each
{
|
group
|
project
.
project_group_links
.
create
(
group:
group
,
group_access:
Gitlab
::
Access
::
DEVELOPER
)
}
end
def
access_type_id
s
(
git_operation
)
def
last_access_level
s
(
git_operation
)
ProtectedBranch
.
last
.
public_send
(
"
#{
git_operation
}
_access_levels"
)
end
def
access_levels
(
access_level_types
)
access_level_types
.
map
(
&
:access_level
)
end
def
user_ids
(
access_level_types
)
access_level_types
.
map
(
&
:user_id
)
end
def
group_ids
(
access_level_types
)
access_level_types
.
map
(
&
:group_id
)
end
it
"allows creating protected branches that roles, users, and groups can
#{
git_operation
}
to"
do
visit
namespace_project_protected_branches_path
(
project
.
namespace
,
project
)
...
...
@@ -42,10 +30,10 @@ shared_examples "protected branches > access control > EE" do
within
(
".protected-branches-list"
)
{
expect
(
page
).
to
have_content
(
'master'
)
}
expect
(
ProtectedBranch
.
count
).
to
eq
(
1
)
access_level
_types
=
access_type_id
s
(
git_operation
)
roles
.
each
{
|
(
access_type_id
,
_
)
|
expect
(
access_levels
(
access_level_types
)).
to
include
(
access_type_id
)
}
users
.
each
{
|
user
|
expect
(
user_ids
(
access_level_types
)).
to
include
(
user
.
id
)
}
groups
.
each
{
|
group
|
expect
(
group_ids
(
access_level_types
)).
to
include
(
group
.
id
)
}
access_level
s
=
last_access_level
s
(
git_operation
)
roles
.
each
{
|
(
access_type_id
,
_
)
|
expect
(
access_levels
.
map
(
&
:access_level
)).
to
include
(
access_type_id
)
}
users
.
each
{
|
user
|
expect
(
access_levels
.
map
(
&
:user_id
)).
to
include
(
user
.
id
)
}
groups
.
each
{
|
group
|
expect
(
access_levels
.
map
(
&
:group_id
)).
to
include
(
group
.
id
)
}
end
it
"allows updating protected branches so that roles and users can
#{
git_operation
}
to it"
do
...
...
@@ -64,10 +52,10 @@ shared_examples "protected branches > access control > EE" do
expect
(
ProtectedBranch
.
count
).
to
eq
(
1
)
access_level
_types
=
access_type_id
s
(
git_operation
)
roles
.
each
{
|
(
access_type_id
,
_
)
|
expect
(
access_levels
(
access_level_types
)).
to
include
(
access_type_id
)
}
users
.
each
{
|
user
|
expect
(
user_ids
(
access_level_types
)).
to
include
(
user
.
id
)
}
groups
.
each
{
|
group
|
expect
(
group_ids
(
access_level_types
)).
to
include
(
group
.
id
)
}
access_level
s
=
last_access_level
s
(
git_operation
)
roles
.
each
{
|
(
access_type_id
,
_
)
|
expect
(
access_levels
.
map
(
&
:access_level
)).
to
include
(
access_type_id
)
}
users
.
each
{
|
user
|
expect
(
access_levels
.
map
(
&
:user_id
)).
to
include
(
user
.
id
)
}
groups
.
each
{
|
group
|
expect
(
access_levels
.
map
(
&
:group_id
)).
to
include
(
group
.
id
)
}
end
it
"allows updating protected branches so that roles and users cannot
#{
git_operation
}
to it"
do
...
...
@@ -89,8 +77,8 @@ shared_examples "protected branches > access control > EE" do
expect
(
ProtectedBranch
.
count
).
to
eq
(
1
)
access_level
_types
=
access_type_id
s
(
git_operation
)
expect
(
access_
type_ids
(
access_level_types
)
).
to
be_empty
access_level
s
=
last_access_level
s
(
git_operation
)
expect
(
access_
levels
).
to
be_empty
end
it
"prepends selected users that can
#{
git_operation
}
to"
do
...
...
@@ -129,9 +117,9 @@ shared_examples "protected branches > access control > EE" do
expect
(
ProtectedBranch
.
count
).
to
eq
(
1
)
access_level
_types
=
access_type_id
s
(
git_operation
)
roles
.
each
{
|
(
access_type_id
,
_
)
|
expect
(
access_levels
(
access_level_types
)).
to
include
(
access_type_id
)
}
expect
(
user_ids
(
git_operation
)).
to
include
(
users
.
last
.
id
)
access_level
s
=
last_access_level
s
(
git_operation
)
roles
.
each
{
|
(
access_type_id
,
_
)
|
expect
(
access_levels
.
map
(
&
:access_level
)).
to
include
(
access_type_id
)
}
expect
(
access_levels
.
map
(
&
:user_id
)).
to
include
(
users
.
last
.
id
)
end
end
...
...
@@ -154,11 +142,11 @@ shared_examples "protected branches > access control > EE" do
wait_for_requests
access_level
_types
=
access_type_id
s
(
'push'
)
access_level
s
=
last_access_level
s
(
'push'
)
roles
.
each
do
|
(
access_type_id
,
_
)
|
expect
(
access_levels
(
access_level_types
)).
not_to
include
(
access_type_id
)
expect
(
access_levels
.
map
(
&
:access_level
)).
not_to
include
(
access_type_id
)
end
expect
(
access_levels
(
access_level_types
)).
to
include
(
0
)
expect
(
access_levels
.
map
(
&
:access_level
)).
to
include
(
0
)
end
end
...
...
@@ -172,11 +160,11 @@ shared_examples "protected branches > access control > EE" do
click_on
"Protect"
wait_for_requests
access_level
_types
=
access_type_id
s
(
'push'
)
access_level
s
=
last_access_level
s
(
'push'
)
roles
.
each
do
|
(
access_type_id
,
_
)
|
expect
(
access_levels
(
access_level_types
)).
not_to
include
(
access_type_id
)
expect
(
access_levels
.
map
(
&
:access_level
)).
not_to
include
(
access_type_id
)
end
expect
(
access_levels
(
access_level_types
)).
to
include
(
0
)
expect
(
access_levels
.
map
(
&
:access_level
)).
to
include
(
0
)
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