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
a66880a3
Commit
a66880a3
authored
Sep 16, 2021
by
Brett Walker
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Convert namespace project? and user? methods
into project_namespace? and user_namespace?
parent
5775623d
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
22 additions
and
22 deletions
+22
-22
app/models/namespace.rb
app/models/namespace.rb
+10
-10
app/models/namespace/root_storage_statistics.rb
app/models/namespace/root_storage_statistics.rb
+1
-1
ee/app/helpers/ee/namespaces_helper.rb
ee/app/helpers/ee/namespaces_helper.rb
+1
-1
ee/app/helpers/ee/search_helper.rb
ee/app/helpers/ee/search_helper.rb
+1
-1
ee/app/services/ci/minutes/additional_packs/change_namespace_service.rb
...s/ci/minutes/additional_packs/change_namespace_service.rb
+1
-1
ee/app/services/ci/minutes/email_notification_service.rb
ee/app/services/ci/minutes/email_notification_service.rb
+1
-1
lib/api/entities/namespace_basic.rb
lib/api/entities/namespace_basic.rb
+1
-1
lib/gitlab/auth.rb
lib/gitlab/auth.rb
+1
-1
spec/models/namespace_spec.rb
spec/models/namespace_spec.rb
+5
-5
No files found.
app/models/namespace.rb
View file @
a66880a3
...
...
@@ -248,7 +248,7 @@ class Namespace < ApplicationRecord
def
kind
return
'group'
if
group?
return
'project'
if
project?
return
'project'
if
project
_namespace
?
'user'
# defaults to user
end
...
...
@@ -257,17 +257,17 @@ class Namespace < ApplicationRecord
type
==
Group
.
sti_name
end
def
project?
def
project
_namespace
?
type
==
Namespaces
::
ProjectNamespace
.
sti_name
end
def
user?
def
user
_namespace
?
# That last bit ensures we're considered a user namespace as a default
type
.
nil?
||
type
==
Namespaces
::
UserNamespace
.
sti_name
||
!
(
group?
||
project?
)
type
.
nil?
||
type
==
Namespaces
::
UserNamespace
.
sti_name
||
!
(
group?
||
project
_namespace
?
)
end
def
owner_required?
user?
user
_namespace
?
end
def
find_fork_of
(
project
)
...
...
@@ -314,7 +314,7 @@ class Namespace < ApplicationRecord
# that belongs to this namespace
def
all_projects
if
Feature
.
enabled?
(
:recursive_approach_for_all_projects
,
default_enabled: :yaml
)
namespace
=
user?
?
self
:
self_and_descendant_ids
namespace
=
user
_namespace
?
?
self
:
self_and_descendant_ids
Project
.
where
(
namespace:
namespace
)
else
Project
.
inside_path
(
full_path
)
...
...
@@ -536,21 +536,21 @@ class Namespace < ApplicationRecord
def
validate_parent_type
unless
has_parent?
if
project?
if
project
_namespace
?
errors
.
add
(
:parent_id
,
_
(
'must be set for a project namespace'
))
end
return
end
if
parent
.
project?
if
parent
.
project
_namespace
?
errors
.
add
(
:parent_id
,
_
(
'project namespace cannot be the parent of another namespace'
))
end
if
user?
if
user
_namespace
?
errors
.
add
(
:parent_id
,
_
(
'cannot not be used for user namespace'
))
elsif
group?
errors
.
add
(
:parent_id
,
_
(
'user namespace cannot be the parent of another namespace'
))
if
parent
.
user?
errors
.
add
(
:parent_id
,
_
(
'user namespace cannot be the parent of another namespace'
))
if
parent
.
user
_namespace
?
end
end
...
...
app/models/namespace/root_storage_statistics.rb
View file @
a66880a3
...
...
@@ -57,7 +57,7 @@ class Namespace::RootStorageStatistics < ApplicationRecord
end
def
attributes_from_personal_snippets
return
{}
unless
namespace
.
user?
return
{}
unless
namespace
.
user
_namespace
?
from_personal_snippets
.
take
.
slice
(
SNIPPETS_SIZE_STAT_NAME
)
end
...
...
ee/app/helpers/ee/namespaces_helper.rb
View file @
a66880a3
...
...
@@ -40,7 +40,7 @@ module EE
end
def
link_to_buy_additional_minutes_path
(
namespace
)
use_customer_dot_path
=
namespace
.
user?
||
::
Feature
.
disabled?
(
:new_route_ci_minutes_purchase
,
namespace
,
default_enabled: :yaml
)
use_customer_dot_path
=
namespace
.
user
_namespace
?
||
::
Feature
.
disabled?
(
:new_route_ci_minutes_purchase
,
namespace
,
default_enabled: :yaml
)
return
EE
::
SUBSCRIPTIONS_MORE_MINUTES_URL
if
use_customer_dot_path
buy_minutes_subscriptions_path
(
selected_group:
namespace
.
id
)
...
...
ee/app/helpers/ee/search_helper.rb
View file @
a66880a3
...
...
@@ -165,7 +165,7 @@ module EE
def
allow_filtering_by_iteration?
# We currently only have group-level iterations so we hide
# this filter for projects under personal namespaces
return
false
if
@project
&&
@project
.
namespace
.
user?
return
false
if
@project
&&
@project
.
namespace
.
user
_namespace
?
context
=
@project
.
presence
||
@group
.
presence
...
...
ee/app/services/ci/minutes/additional_packs/change_namespace_service.rb
View file @
a66880a3
...
...
@@ -62,7 +62,7 @@ module Ci
end
def
owner_ids_for
(
namespace
)
namespace
.
user?
?
Array
(
namespace
.
owner_id
)
:
namespace
.
owner_ids
namespace
.
user
_namespace
?
?
Array
(
namespace
.
owner_id
)
:
namespace
.
owner_ids
end
end
end
...
...
ee/app/services/ci/minutes/email_notification_service.rb
View file @
a66880a3
...
...
@@ -58,7 +58,7 @@ module Ci
end
def
recipients
namespace
.
user?
?
[
namespace
.
owner_email
]
:
namespace
.
owners_emails
namespace
.
user
_namespace
?
?
[
namespace
.
owner_email
]
:
namespace
.
owners_emails
end
def
namespace
...
...
lib/api/entities/namespace_basic.rb
View file @
a66880a3
...
...
@@ -6,7 +6,7 @@ module API
expose
:id
,
:name
,
:path
,
:kind
,
:full_path
,
:parent_id
,
:avatar_url
expose
:web_url
do
|
namespace
|
if
namespace
.
user?
if
namespace
.
user
_namespace
?
Gitlab
::
Routing
.
url_helpers
.
user_url
(
namespace
.
owner
)
else
namespace
.
web_url
...
...
lib/gitlab/auth.rb
View file @
a66880a3
...
...
@@ -283,7 +283,7 @@ module Gitlab
token_handler
=
Gitlab
::
LfsToken
.
new
(
actor
)
authentication_abilities
=
if
token_handler
.
user?
if
token_handler
.
user
_namespace
?
read_write_project_authentication_abilities
elsif
token_handler
.
deploy_key_pushable?
(
project
)
read_write_authentication_abilities
...
...
spec/models/namespace_spec.rb
View file @
a66880a3
...
...
@@ -186,7 +186,7 @@ RSpec.describe Namespace do
it
'is valid'
do
expect
(
Namespace
.
find
(
namespace
.
id
)).
to
be_a
(
Namespaces
::
ProjectNamespace
)
expect
(
namespace
.
kind
).
to
eq
(
'project'
)
expect
(
namespace
.
project?
).
to
be_truthy
expect
(
namespace
.
project
_namespace
?
).
to
be_truthy
end
end
...
...
@@ -198,7 +198,7 @@ RSpec.describe Namespace do
# https://gitlab.com/gitlab-org/gitlab/-/merge_requests/68894 is ready
expect
(
Namespace
.
find
(
namespace
.
id
)).
to
be_a
(
Namespace
)
expect
(
namespace
.
kind
).
to
eq
(
'user'
)
expect
(
namespace
.
user?
).
to
be_truthy
expect
(
namespace
.
user
_namespace
?
).
to
be_truthy
end
end
...
...
@@ -208,7 +208,7 @@ RSpec.describe Namespace do
it
'is valid'
do
expect
(
Namespace
.
find
(
namespace
.
id
)).
to
be_a
(
Namespace
)
expect
(
namespace
.
kind
).
to
eq
(
'user'
)
expect
(
namespace
.
user?
).
to
be_truthy
expect
(
namespace
.
user
_namespace
?
).
to
be_truthy
end
end
...
...
@@ -218,7 +218,7 @@ RSpec.describe Namespace do
it
'defaults to a Namespace'
do
expect
(
Namespace
.
find
(
namespace
.
id
)).
to
be_a
(
Namespace
)
expect
(
namespace
.
kind
).
to
eq
(
'user'
)
expect
(
namespace
.
user?
).
to
be_truthy
expect
(
namespace
.
user
_namespace
?
).
to
be_truthy
end
end
end
...
...
@@ -1559,7 +1559,7 @@ RSpec.describe Namespace do
end
describe
'#user?'
do
subject
{
namespace
.
user?
}
subject
{
namespace
.
user
_namespace
?
}
context
'when type is a user'
do
let
(
:user
)
{
create
(
:user
)
}
...
...
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