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
a0cc2986
Commit
a0cc2986
authored
Dec 03, 2021
by
charlie ablett
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove redundant condition from UserNamespace policy
parent
de796cf9
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
23 additions
and
3 deletions
+23
-3
app/policies/namespace_policy.rb
app/policies/namespace_policy.rb
+0
-1
app/policies/namespaces/user_namespace_policy.rb
app/policies/namespaces/user_namespace_policy.rb
+1
-2
spec/policies/namespaces/user_namespace_policy_spec.rb
spec/policies/namespaces/user_namespace_policy_spec.rb
+22
-0
No files found.
app/policies/namespace_policy.rb
View file @
a0cc2986
...
@@ -8,4 +8,3 @@ class NamespacePolicy < BasePolicy
...
@@ -8,4 +8,3 @@ class NamespacePolicy < BasePolicy
# here.
# here.
# See https://gitlab.com/groups/gitlab-org/-/epics/6689 for details
# See https://gitlab.com/groups/gitlab-org/-/epics/6689 for details
end
end
app/policies/namespaces/user_namespace_policy.rb
View file @
a0cc2986
...
@@ -4,7 +4,6 @@ module Namespaces
...
@@ -4,7 +4,6 @@ module Namespaces
class
UserNamespacePolicy
<
::
NamespacePolicy
class
UserNamespacePolicy
<
::
NamespacePolicy
rule
{
anonymous
}.
prevent_all
rule
{
anonymous
}.
prevent_all
condition
(
:personal_project
,
scope: :subject
)
{
@subject
.
kind
==
'user'
}
condition
(
:can_create_personal_project
,
scope: :user
)
{
@user
.
can_create_project?
}
condition
(
:can_create_personal_project
,
scope: :user
)
{
@user
.
can_create_project?
}
condition
(
:owner
)
{
@subject
.
owner
==
@user
}
condition
(
:owner
)
{
@subject
.
owner
==
@user
}
...
@@ -19,7 +18,7 @@ module Namespaces
...
@@ -19,7 +18,7 @@ module Namespaces
enable
:read_package_settings
enable
:read_package_settings
end
end
rule
{
personal_project
&
~
can_create_personal_project
}.
prevent
:create_projects
rule
{
~
can_create_personal_project
}.
prevent
:create_projects
rule
{
(
owner
|
admin
)
&
can?
(
:create_projects
)
}.
enable
:transfer_projects
rule
{
(
owner
|
admin
)
&
can?
(
:create_projects
)
}.
enable
:transfer_projects
end
end
...
...
spec/policies/namespaces/user_namespace_policy_spec.rb
View file @
a0cc2986
...
@@ -74,4 +74,26 @@ RSpec.describe Namespaces::UserNamespacePolicy do
...
@@ -74,4 +74,26 @@ RSpec.describe Namespaces::UserNamespacePolicy do
it
{
is_expected
.
to
be_disallowed
(
:create_jira_connect_subscription
)
}
it
{
is_expected
.
to
be_disallowed
(
:create_jira_connect_subscription
)
}
end
end
end
end
describe
'create projects'
do
using
RSpec
::
Parameterized
::
TableSyntax
let
(
:current_user
)
{
owner
}
context
'when user can create projects'
do
before
do
allow
(
current_user
).
to
receive
(
:can_create_project?
).
and_return
(
true
)
end
it
{
is_expected
.
to
be_allowed
(
:create_projects
)
}
end
context
'when user cannot create projects'
do
before
do
allow
(
current_user
).
to
receive
(
:can_create_project?
).
and_return
(
false
)
end
it
{
is_expected
.
to
be_disallowed
(
:create_projects
)
}
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