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
4804df2e
Commit
4804df2e
authored
Sep 22, 2021
by
Brett Walker
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Address reviewer comments
particuarly adding TODO comments where code is temporary.
parent
e358cac8
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
17 additions
and
5 deletions
+17
-5
app/models/namespace.rb
app/models/namespace.rb
+2
-0
app/models/namespaces/user_namespace.rb
app/models/namespaces/user_namespace.rb
+1
-1
app/models/user.rb
app/models/user.rb
+2
-0
ee/app/models/ee/user.rb
ee/app/models/ee/user.rb
+4
-0
ee/spec/models/ee/user_spec.rb
ee/spec/models/ee/user_spec.rb
+2
-0
spec/models/namespace_spec.rb
spec/models/namespace_spec.rb
+4
-4
spec/models/user_spec.rb
spec/models/user_spec.rb
+2
-0
No files found.
app/models/namespace.rb
View file @
4804df2e
...
...
@@ -101,6 +101,8 @@ class Namespace < ApplicationRecord
saved_change_to_name?
||
saved_change_to_path?
||
saved_change_to_parent_id?
}
# TODO: change to `type: Namespaces::UserNamespace.sti_name` when
# working on issue https://gitlab.com/gitlab-org/gitlab/-/issues/341070
scope
:user_namespaces
,
->
{
where
(
type:
[
nil
,
Namespaces
::
UserNamespace
.
sti_name
])
}
scope
:sort_by_type
,
->
{
order
(
Gitlab
::
Database
.
nulls_first_order
(
:type
))
}
scope
:include_route
,
->
{
includes
(
:route
)
}
...
...
app/models/namespaces/user_namespace.rb
View file @
4804df2e
# frozen_string_literal: true
# TODO: currently not created/mapped in the database, will be done in another issue
# https://gitlab.com/gitlab-org/gitlab/-/issues/3
37102
# https://gitlab.com/gitlab-org/gitlab/-/issues/3
41070
module
Namespaces
class
UserNamespace
<
Namespace
def
self
.
sti_name
...
...
app/models/user.rb
View file @
4804df2e
...
...
@@ -112,6 +112,8 @@ class User < ApplicationRecord
#
# Namespace for personal projects
# TODO: change to `type: Namespaces::UserNamespace.sti_name` when
# working on issue https://gitlab.com/gitlab-org/gitlab/-/issues/341070
has_one
:namespace
,
->
{
where
(
type:
[
nil
,
Namespaces
::
UserNamespace
.
sti_name
])
},
dependent: :destroy
,
foreign_key: :owner_id
,
inverse_of: :owner
,
autosave:
true
# rubocop:disable Cop/ActiveRecordDependent
# Profile
...
...
ee/app/models/ee/user.rb
View file @
4804df2e
...
...
@@ -452,6 +452,8 @@ module EE
end
end
# TODO: change to `type: ::Namespaces::UserNamespace.sti_name` when
# working on issue https://gitlab.com/gitlab-org/gitlab/-/issues/341070
def
namespace_union_for_owned
(
select
=
:id
)
::
Gitlab
::
SQL
::
Union
.
new
([
::
Namespace
.
select
(
select
).
where
(
type:
[
nil
,
::
Namespaces
::
UserNamespace
.
sti_name
],
owner:
self
),
...
...
@@ -459,6 +461,8 @@ module EE
]).
to_sql
end
# TODO: change to `type: ::Namespaces::UserNamespace.sti_name` when
# working on issue https://gitlab.com/gitlab-org/gitlab/-/issues/341070
def
namespace_union_for_reporter_developer_maintainer_owned
(
select
=
:id
)
::
Gitlab
::
SQL
::
Union
.
new
([
::
Namespace
.
select
(
select
).
where
(
type:
[
nil
,
::
Namespaces
::
UserNamespace
.
sti_name
],
owner:
self
),
...
...
ee/spec/models/ee/user_spec.rb
View file @
4804df2e
...
...
@@ -1343,6 +1343,8 @@ RSpec.describe User do
let_it_be
(
:free_group
)
{
create
(
:group_with_plan
,
plan: :free_plan
)
}
let_it_be
(
:group_without_plan
)
{
create
(
:group
)
}
# TODO: this `where/when` can be removed in issue https://gitlab.com/gitlab-org/gitlab/-/issues/341070
# At that point we only need to check `user_namespace`
where
(
namespace_type:
[
:namespace
,
:user_namespace
])
with_them
do
...
...
spec/models/namespace_spec.rb
View file @
4804df2e
...
...
@@ -178,7 +178,7 @@ RSpec.describe Namespace do
context
'creating a Group'
do
let
(
:namespace_type
)
{
group_sti_name
}
it
'is
valid
'
do
it
'is
the correct type of namespace
'
do
expect
(
namespace
).
to
be_a
(
Group
)
expect
(
namespace
.
kind
).
to
eq
(
'group'
)
expect
(
namespace
.
group_namespace?
).
to
be_truthy
...
...
@@ -189,7 +189,7 @@ RSpec.describe Namespace do
let
(
:namespace_type
)
{
project_sti_name
}
let
(
:parent
)
{
create
(
:group
)
}
it
'is
valid
'
do
it
'is
the correct type of namespace
'
do
expect
(
Namespace
.
find
(
namespace
.
id
)).
to
be_a
(
Namespaces
::
ProjectNamespace
)
expect
(
namespace
.
kind
).
to
eq
(
'project'
)
expect
(
namespace
.
project_namespace?
).
to
be_truthy
...
...
@@ -199,7 +199,7 @@ RSpec.describe Namespace do
context
'creating a UserNamespace'
do
let
(
:namespace_type
)
{
user_sti_name
}
it
'is
valid
'
do
it
'is
the correct type of namespace
'
do
expect
(
Namespace
.
find
(
namespace
.
id
)).
to
be_a
(
Namespaces
::
UserNamespace
)
expect
(
namespace
.
kind
).
to
eq
(
'user'
)
expect
(
namespace
.
user_namespace?
).
to
be_truthy
...
...
@@ -209,7 +209,7 @@ RSpec.describe Namespace do
context
'creating a default Namespace'
do
let
(
:namespace_type
)
{
nil
}
it
'is
valid
'
do
it
'is
the correct type of namespace
'
do
expect
(
Namespace
.
find
(
namespace
.
id
)).
to
be_a
(
Namespace
)
expect
(
namespace
.
kind
).
to
eq
(
'user'
)
expect
(
namespace
.
user_namespace?
).
to
be_truthy
...
...
spec/models/user_spec.rb
View file @
4804df2e
...
...
@@ -2544,6 +2544,8 @@ RSpec.describe User do
describe
'.find_by_full_path'
do
using
RSpec
::
Parameterized
::
TableSyntax
# TODO: this `where/when` can be removed in issue https://gitlab.com/gitlab-org/gitlab/-/issues/341070
# At that point we only need to check `user_namespace`
where
(
namespace_type:
[
:namespace
,
:user_namespace
])
with_them
do
...
...
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