BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
f144cce8
Unverified
Commit
f144cce8
authored
Nov 27, 2017
by
Tomasz Maczukin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update policies unit tests
This commit also makes spec/policies/namespace_policy_spec.rb file to be compatible with the same file in GitLab EE.
parent
a9212e0f
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
37 additions
and
14 deletions
+37
-14
group_policy_spec.rb
spec/policies/group_policy_spec.rb
+7
-6
namespace_policy_spec.rb
spec/policies/namespace_policy_spec.rb
+30
-8
No files found.
spec/policies/group_policy_spec.rb
View file @
f144cce8
...
...
@@ -56,6 +56,7 @@ describe GroupPolicy do
expect_disallowed
(
*
developer_permissions
)
expect_disallowed
(
*
master_permissions
)
expect_disallowed
(
*
owner_permissions
)
expect_disallowed
(
:read_namespace
)
end
end
...
...
@@ -63,7 +64,7 @@ describe GroupPolicy do
let
(
:current_user
)
{
guest
}
it
do
expect_allowed
(
:read_group
)
expect_allowed
(
:read_group
,
:read_namespace
)
expect_disallowed
(
*
reporter_permissions
)
expect_disallowed
(
*
developer_permissions
)
expect_disallowed
(
*
master_permissions
)
...
...
@@ -75,7 +76,7 @@ describe GroupPolicy do
let
(
:current_user
)
{
reporter
}
it
do
expect_allowed
(
:read_group
)
expect_allowed
(
:read_group
,
:read_namespace
)
expect_allowed
(
*
reporter_permissions
)
expect_disallowed
(
*
developer_permissions
)
expect_disallowed
(
*
master_permissions
)
...
...
@@ -87,7 +88,7 @@ describe GroupPolicy do
let
(
:current_user
)
{
developer
}
it
do
expect_allowed
(
:read_group
)
expect_allowed
(
:read_group
,
:read_namespace
)
expect_allowed
(
*
reporter_permissions
)
expect_allowed
(
*
developer_permissions
)
expect_disallowed
(
*
master_permissions
)
...
...
@@ -99,7 +100,7 @@ describe GroupPolicy do
let
(
:current_user
)
{
master
}
it
do
expect_allowed
(
:read_group
)
expect_allowed
(
:read_group
,
:read_namespace
)
expect_allowed
(
*
reporter_permissions
)
expect_allowed
(
*
developer_permissions
)
expect_allowed
(
*
master_permissions
)
...
...
@@ -113,7 +114,7 @@ describe GroupPolicy do
it
do
allow
(
Group
).
to
receive
(
:supports_nested_groups?
).
and_return
(
true
)
expect_allowed
(
:read_group
)
expect_allowed
(
:read_group
,
:read_namespace
)
expect_allowed
(
*
reporter_permissions
)
expect_allowed
(
*
developer_permissions
)
expect_allowed
(
*
master_permissions
)
...
...
@@ -127,7 +128,7 @@ describe GroupPolicy do
it
do
allow
(
Group
).
to
receive
(
:supports_nested_groups?
).
and_return
(
true
)
expect_allowed
(
:read_group
)
expect_allowed
(
:read_group
,
:read_namespace
)
expect_allowed
(
*
reporter_permissions
)
expect_allowed
(
*
developer_permissions
)
expect_allowed
(
*
master_permissions
)
...
...
spec/policies/namespace_policy_spec.rb
View file @
f144cce8
require
'spec_helper'
describe
NamespacePolicy
do
let
(
:current_user
)
{
create
(
:user
)
}
let
(
:namespace
)
{
current_user
.
namespace
}
let
(
:user
)
{
create
(
:user
)
}
let
(
:owner
)
{
create
(
:user
)
}
let
(
:admin
)
{
create
(
:admin
)
}
let
(
:namespace
)
{
create
(
:namespace
,
owner:
owner
)
}
let
(
:owner_permissions
)
{
[
:create_projects
,
:admin_namespace
,
:read_namespace
]
}
subject
{
described_class
.
new
(
current_user
,
namespace
)
}
context
"create projects"
do
context
"user namespace"
do
it
{
is_expected
.
to
be_allowed
(
:create_projects
)
}
end
context
'with no user'
do
let
(
:current_user
)
{
nil
}
it
{
is_expected
.
to
be_banned
}
end
context
'regular user'
do
let
(
:current_user
)
{
user
}
it
{
is_expected
.
to
be_disallowed
(
*
owner_permissions
)
}
end
context
'owner'
do
let
(
:current_user
)
{
owner
}
it
{
is_expected
.
to
be_allowed
(
*
owner_permissions
)
}
context
"user who has exceeded project limit"
do
let
(
:
current_us
er
)
{
create
(
:user
,
projects_limit:
0
)
}
context
'user who has exceeded project limit'
do
let
(
:
own
er
)
{
create
(
:user
,
projects_limit:
0
)
}
it
{
is_expected
.
not_to
be_allowed
(
:create_projects
)
}
end
end
context
'admin'
do
let
(
:current_user
)
{
admin
}
it
{
is_expected
.
to
be_allowed
(
*
owner_permissions
)
}
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