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
b3352abb
Commit
b3352abb
authored
Jun 27, 2017
by
Rémy Coutable
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move shared examples to their correct location and remove duplicates
Signed-off-by:
Rémy Coutable
<
remy@rymai.me
>
parent
6639a3cd
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
2 additions
and
249 deletions
+2
-249
spec/support/protected_branches/access_control_ee_shared_examples.rb
...t/protected_branches/access_control_ee_shared_examples.rb
+0
-156
spec/support/shared_examples/features/protected_branches_access_control_ce.rb
...examples/features/protected_branches_access_control_ce.rb
+2
-2
spec/support/shared_examples/features/protected_branches_access_control_ce_spec.rb
...les/features/protected_branches_access_control_ce_spec.rb
+0
-91
spec/support/shared_examples/features/protected_branches_access_control_ee.rb
...examples/features/protected_branches_access_control_ee.rb
+0
-0
No files found.
spec/support/protected_branches/access_control_ee_shared_examples.rb
deleted
100644 → 0
View file @
6639a3cd
RSpec
.
shared_examples
"protected branches > access control > EE"
do
[[
'merge'
,
ProtectedBranch
::
MergeAccessLevel
],
[
'push'
,
ProtectedBranch
::
PushAccessLevel
]].
each
do
|
git_operation
,
access_level_class
|
# Need to set a default for the `git_operation` access level that _isn't_ being tested
other_git_operation
=
git_operation
==
'merge'
?
'push'
:
'merge'
roles
=
git_operation
==
'merge'
?
access_level_class
.
human_access_levels
:
access_level_class
.
human_access_levels
.
except
(
0
)
let
(
:users
)
{
create_list
(
:user
,
5
)
}
let
(
:groups
)
{
create_list
(
:group
,
5
)
}
before
do
users
.
each
{
|
user
|
project
.
team
<<
[
user
,
:developer
]
}
groups
.
each
{
|
group
|
project
.
project_group_links
.
create
(
group:
group
,
group_access:
Gitlab
::
Access
::
DEVELOPER
)
}
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
)
set_protected_branch_name
(
'master'
)
set_allowed_to
(
git_operation
,
users
.
map
(
&
:name
))
set_allowed_to
(
git_operation
,
groups
.
map
(
&
:name
))
set_allowed_to
(
git_operation
,
roles
.
values
)
set_allowed_to
(
other_git_operation
)
click_on
"Protect"
within
(
".protected-branches-list"
)
{
expect
(
page
).
to
have_content
(
'master'
)
}
expect
(
ProtectedBranch
.
count
).
to
eq
(
1
)
roles
.
each
{
|
(
access_type_id
,
_
)
|
expect
(
ProtectedBranch
.
last
.
send
(
"
#{
git_operation
}
_access_levels"
.
to_sym
).
map
(
&
:access_level
)).
to
include
(
access_type_id
)
}
users
.
each
{
|
user
|
expect
(
ProtectedBranch
.
last
.
send
(
"
#{
git_operation
}
_access_levels"
.
to_sym
).
map
(
&
:user_id
)).
to
include
(
user
.
id
)
}
groups
.
each
{
|
group
|
expect
(
ProtectedBranch
.
last
.
send
(
"
#{
git_operation
}
_access_levels"
.
to_sym
).
map
(
&
:group_id
)).
to
include
(
group
.
id
)
}
end
it
"allows updating protected branches so that roles and users can
#{
git_operation
}
to it"
do
visit
namespace_project_protected_branches_path
(
project
.
namespace
,
project
)
set_protected_branch_name
(
'master'
)
set_allowed_to
(
'merge'
)
set_allowed_to
(
'push'
)
click_on
"Protect"
set_allowed_to
(
git_operation
,
users
.
map
(
&
:name
),
form:
".js-protected-branch-edit-form"
)
set_allowed_to
(
git_operation
,
groups
.
map
(
&
:name
),
form:
".js-protected-branch-edit-form"
)
set_allowed_to
(
git_operation
,
roles
.
values
,
form:
".js-protected-branch-edit-form"
)
wait_for_requests
expect
(
ProtectedBranch
.
count
).
to
eq
(
1
)
roles
.
each
{
|
(
access_type_id
,
_
)
|
expect
(
ProtectedBranch
.
last
.
send
(
"
#{
git_operation
}
_access_levels"
.
to_sym
).
map
(
&
:access_level
)).
to
include
(
access_type_id
)
}
users
.
each
{
|
user
|
expect
(
ProtectedBranch
.
last
.
send
(
"
#{
git_operation
}
_access_levels"
.
to_sym
).
map
(
&
:user_id
)).
to
include
(
user
.
id
)
}
groups
.
each
{
|
group
|
expect
(
ProtectedBranch
.
last
.
send
(
"
#{
git_operation
}
_access_levels"
.
to_sym
).
map
(
&
:group_id
)).
to
include
(
group
.
id
)
}
end
it
"allows updating protected branches so that roles and users cannot
#{
git_operation
}
to it"
do
visit
namespace_project_protected_branches_path
(
project
.
namespace
,
project
)
set_protected_branch_name
(
'master'
)
users
.
each
{
|
user
|
set_allowed_to
(
git_operation
,
user
.
name
)
}
roles
.
each
{
|
(
_
,
access_type_name
)
|
set_allowed_to
(
git_operation
,
access_type_name
)
}
groups
.
each
{
|
group
|
set_allowed_to
(
git_operation
,
group
.
name
)
}
set_allowed_to
(
other_git_operation
)
click_on
"Protect"
users
.
each
{
|
user
|
set_allowed_to
(
git_operation
,
user
.
name
,
form:
".js-protected-branch-edit-form"
)
}
groups
.
each
{
|
group
|
set_allowed_to
(
git_operation
,
group
.
name
,
form:
".js-protected-branch-edit-form"
)
}
roles
.
each
{
|
(
_
,
access_type_name
)
|
set_allowed_to
(
git_operation
,
access_type_name
,
form:
".js-protected-branch-edit-form"
)
}
wait_for_requests
expect
(
ProtectedBranch
.
count
).
to
eq
(
1
)
expect
(
ProtectedBranch
.
last
.
send
(
"
#{
git_operation
}
_access_levels"
.
to_sym
)).
to
be_empty
end
it
"prepends selected users that can
#{
git_operation
}
to"
do
users
=
create_list
(
:user
,
21
)
users
.
each
{
|
user
|
project
.
team
<<
[
user
,
:developer
]
}
visit
namespace_project_protected_branches_path
(
project
.
namespace
,
project
)
# Create Protected Branch
set_protected_branch_name
(
'master'
)
set_allowed_to
(
git_operation
,
roles
.
values
)
set_allowed_to
(
other_git_operation
)
click_on
'Protect'
# Update Protected Branch
within
(
".protected-branches-list"
)
do
find
(
".js-allowed-to-
#{
git_operation
}
"
).
click
find
(
".dropdown-input-field"
).
set
(
users
.
last
.
name
)
# Find a user that is not loaded
expect
(
page
).
to
have_selector
(
'.dropdown-header'
,
count:
3
)
%w{Roles Groups Users}
.
each_with_index
do
|
header
,
index
|
expect
(
all
(
'.dropdown-header'
)[
index
]).
to
have_content
(
header
)
end
wait_for_requests
click_on
users
.
last
.
name
find
(
".js-allowed-to-
#{
git_operation
}
"
).
click
# close
end
wait_for_requests
# Verify the user is appended in the dropdown
find
(
".protected-branches-list .js-allowed-to-
#{
git_operation
}
"
).
click
expect
(
page
).
to
have_selector
'.dropdown-content .is-active'
,
text:
users
.
last
.
name
expect
(
ProtectedBranch
.
count
).
to
eq
(
1
)
roles
.
each
{
|
(
access_type_id
,
_
)
|
expect
(
ProtectedBranch
.
last
.
send
(
"
#{
git_operation
}
_access_levels"
.
to_sym
).
map
(
&
:access_level
)).
to
include
(
access_type_id
)
}
expect
(
ProtectedBranch
.
last
.
send
(
"
#{
git_operation
}
_access_levels"
.
to_sym
).
map
(
&
:user_id
)).
to
include
(
users
.
last
.
id
)
end
end
context
'When updating a protected branch'
do
it
'discards other roles when choosing "No one"'
do
roles
=
ProtectedBranch
::
PushAccessLevel
.
human_access_levels
.
except
(
0
)
visit
namespace_project_protected_branches_path
(
project
.
namespace
,
project
)
set_protected_branch_name
(
'fix'
)
set_allowed_to
(
'merge'
)
set_allowed_to
(
'push'
,
roles
.
values
)
click_on
"Protect"
wait_for_requests
roles
.
each
do
|
(
access_type_id
,
_
)
|
expect
(
ProtectedBranch
.
last
.
push_access_levels
.
map
(
&
:access_level
)).
to
include
(
access_type_id
)
end
expect
(
ProtectedBranch
.
last
.
push_access_levels
.
map
(
&
:access_level
)).
not_to
include
(
0
)
set_allowed_to
(
'push'
,
'No one'
,
form:
'.js-protected-branch-edit-form'
)
wait_for_requests
roles
.
each
do
|
(
access_type_id
,
_
)
|
expect
(
ProtectedBranch
.
last
.
push_access_levels
.
map
(
&
:access_level
)).
not_to
include
(
access_type_id
)
end
expect
(
ProtectedBranch
.
last
.
push_access_levels
.
map
(
&
:access_level
)).
to
include
(
0
)
end
end
context
'When creating a protected branch'
do
it
'discards other roles when choosing "No one"'
do
roles
=
ProtectedBranch
::
PushAccessLevel
.
human_access_levels
.
except
(
0
)
visit
namespace_project_protected_branches_path
(
project
.
namespace
,
project
)
set_protected_branch_name
(
'master'
)
set_allowed_to
(
'merge'
)
set_allowed_to
(
'push'
,
ProtectedBranch
::
PushAccessLevel
.
human_access_levels
.
values
)
# Last item (No one) should deselect the other ones
click_on
"Protect"
wait_for_requests
roles
.
each
do
|
(
access_type_id
,
_
)
|
expect
(
ProtectedBranch
.
last
.
push_access_levels
.
map
(
&
:access_level
)).
not_to
include
(
access_type_id
)
end
expect
(
ProtectedBranch
.
last
.
push_access_levels
.
map
(
&
:access_level
)).
to
include
(
0
)
end
end
end
spec/support/
protected_branches/access_control_ce_shared_examples
.rb
→
spec/support/
shared_examples/features/protected_branches_access_control_ce
.rb
View file @
b3352abb
RSpec
.
shared_examples
"protected branches > access control > CE"
do
shared_examples
"protected branches > access control > CE"
do
ProtectedBranch
::
PushAccessLevel
.
human_access_levels
.
each
do
|
(
access_type_id
,
access_type_name
)
|
it
"allows creating protected branches that
#{
access_type_name
}
can push to"
do
visit
namespace_project_protected_branches_path
(
project
.
namespace
,
project
)
...
...
@@ -31,7 +31,7 @@ RSpec.shared_examples "protected branches > access control > CE" do
within
(
".protected-branches-list"
)
do
find
(
".js-allowed-to-push"
).
click
within
(
'.js-allowed-to-push-container'
)
do
expect
(
first
(
"li"
)).
to
have_content
(
"Roles"
)
click_on
access_type_name
...
...
spec/support/shared_examples/features/protected_branches_access_control_ce_spec.rb
deleted
100644 → 0
View file @
6639a3cd
shared_examples
"protected branches > access control > CE"
do
ProtectedBranch
::
PushAccessLevel
.
human_access_levels
.
each
do
|
(
access_type_id
,
access_type_name
)
|
it
"allows creating protected branches that
#{
access_type_name
}
can push to"
do
visit
namespace_project_protected_branches_path
(
project
.
namespace
,
project
)
set_protected_branch_name
(
'master'
)
within
(
'.js-new-protected-branch'
)
do
allowed_to_push_button
=
find
(
".js-allowed-to-push"
)
unless
allowed_to_push_button
.
text
==
access_type_name
allowed_to_push_button
.
trigger
(
'click'
)
within
(
".dropdown.open .dropdown-menu"
)
{
click_on
access_type_name
}
end
end
click_on
"Protect"
expect
(
ProtectedBranch
.
count
).
to
eq
(
1
)
expect
(
ProtectedBranch
.
last
.
push_access_levels
.
map
(
&
:access_level
)).
to
eq
([
access_type_id
])
end
it
"allows updating protected branches so that
#{
access_type_name
}
can push to them"
do
visit
namespace_project_protected_branches_path
(
project
.
namespace
,
project
)
set_protected_branch_name
(
'master'
)
click_on
"Protect"
expect
(
ProtectedBranch
.
count
).
to
eq
(
1
)
within
(
".protected-branches-list"
)
do
find
(
".js-allowed-to-push"
).
click
within
(
'.js-allowed-to-push-container'
)
do
expect
(
first
(
"li"
)).
to
have_content
(
"Roles"
)
click_on
access_type_name
end
end
wait_for_requests
expect
(
ProtectedBranch
.
last
.
push_access_levels
.
map
(
&
:access_level
)).
to
include
(
access_type_id
)
end
end
ProtectedBranch
::
MergeAccessLevel
.
human_access_levels
.
each
do
|
(
access_type_id
,
access_type_name
)
|
it
"allows creating protected branches that
#{
access_type_name
}
can merge to"
do
visit
namespace_project_protected_branches_path
(
project
.
namespace
,
project
)
set_protected_branch_name
(
'master'
)
within
(
'.js-new-protected-branch'
)
do
allowed_to_merge_button
=
find
(
".js-allowed-to-merge"
)
unless
allowed_to_merge_button
.
text
==
access_type_name
allowed_to_merge_button
.
click
within
(
".dropdown.open .dropdown-menu"
)
{
click_on
access_type_name
}
end
end
click_on
"Protect"
expect
(
ProtectedBranch
.
count
).
to
eq
(
1
)
expect
(
ProtectedBranch
.
last
.
merge_access_levels
.
map
(
&
:access_level
)).
to
eq
([
access_type_id
])
end
it
"allows updating protected branches so that
#{
access_type_name
}
can merge to them"
do
visit
namespace_project_protected_branches_path
(
project
.
namespace
,
project
)
set_protected_branch_name
(
'master'
)
click_on
"Protect"
expect
(
ProtectedBranch
.
count
).
to
eq
(
1
)
within
(
".protected-branches-list"
)
do
find
(
".js-allowed-to-merge"
).
click
within
(
'.js-allowed-to-merge-container'
)
do
expect
(
first
(
"li"
)).
to
have_content
(
"Roles"
)
click_on
access_type_name
end
end
wait_for_requests
expect
(
ProtectedBranch
.
last
.
merge_access_levels
.
map
(
&
:access_level
)).
to
include
(
access_type_id
)
end
end
end
spec/support/shared_examples/features/protected_branches_access_control_ee
_spec
.rb
→
spec/support/shared_examples/features/protected_branches_access_control_ee.rb
View file @
b3352abb
File moved
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