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
0
Merge Requests
0
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
Léo-Paul Géneau
gitlab-ce
Commits
2e2a63c8
Commit
2e2a63c8
authored
Apr 30, 2017
by
Bob Van Landuyt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rename child namespaces in migrationhelpers
parent
08b1bc34
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
40 additions
and
16 deletions
+40
-16
db/post_migrate/20170412174900_rename_reserved_dynamic_paths.rb
...t_migrate/20170412174900_rename_reserved_dynamic_paths.rb
+11
-0
lib/gitlab/database/rename_reserved_paths_migration/v1.rb
lib/gitlab/database/rename_reserved_paths_migration/v1.rb
+6
-1
lib/gitlab/database/rename_reserved_paths_migration/v1/rename_namespaces.rb
...e/rename_reserved_paths_migration/v1/rename_namespaces.rb
+1
-1
spec/lib/gitlab/database/rename_reserved_paths_migration/v1/rename_namespaces_spec.rb
...ame_reserved_paths_migration/v1/rename_namespaces_spec.rb
+4
-4
spec/lib/gitlab/database/rename_reserved_paths_migration/v1_spec.rb
...itlab/database/rename_reserved_paths_migration/v1_spec.rb
+18
-10
No files found.
db/post_migrate/20170412174900_rename_reserved_dynamic_paths.rb
View file @
2e2a63c8
...
...
@@ -23,6 +23,7 @@ class RenameReservedDynamicPaths < ActiveRecord::Migration
notification_settings
oauth
sent_notifications
unicorn_test
uploads
users
]
...
...
@@ -33,9 +34,19 @@ class RenameReservedDynamicPaths < ActiveRecord::Migration
info/lfs/objects
]
DISSALLOWED_GROUP_PATHS
=
%w[
activity
avatar
group_members
labels
milestones
subgroups
]
def
up
rename_root_paths
(
DISALLOWED_ROOT_PATHS
)
rename_wildcard_paths
(
DISALLOWED_WILDCARD_PATHS
)
rename_child_paths
(
DISSALLOWED_GROUP_PATHS
)
end
def
down
...
...
lib/gitlab/database/rename_reserved_paths_migration/v1.rb
View file @
2e2a63c8
...
...
@@ -7,11 +7,16 @@ module Gitlab
end
def
rename_wildcard_paths
(
one_or_more_paths
)
rename_child_paths
(
one_or_more_paths
)
paths
=
Array
(
one_or_more_paths
)
RenameNamespaces
.
new
(
paths
,
self
).
rename_namespaces
(
type: :wildcard
)
RenameProjects
.
new
(
paths
,
self
).
rename_projects
end
def
rename_child_paths
(
one_or_more_paths
)
paths
=
Array
(
one_or_more_paths
)
RenameNamespaces
.
new
(
paths
,
self
).
rename_namespaces
(
type: :child
)
end
def
rename_root_paths
(
paths
)
paths
=
Array
(
paths
)
RenameNamespaces
.
new
(
paths
,
self
).
rename_namespaces
(
type: :top_level
)
...
...
lib/gitlab/database/rename_reserved_paths_migration/v1/rename_namespaces.rb
View file @
2e2a63c8
...
...
@@ -13,7 +13,7 @@ module Gitlab
def
namespaces_for_paths
(
type
:)
namespaces
=
case
type
when
:
wildcar
d
when
:
chil
d
MigrationClasses
::
Namespace
.
where
.
not
(
parent_id:
nil
)
when
:top_level
MigrationClasses
::
Namespace
.
where
(
parent_id:
nil
)
...
...
spec/lib/gitlab/database/rename_reserved_paths_migration/v1/rename_namespaces_spec.rb
View file @
2e2a63c8
...
...
@@ -21,13 +21,13 @@ describe Gitlab::Database::RenameReservedPathsMigration::V1::RenameNamespaces do
parent
=
create
(
:namespace
,
path:
'parent'
)
child
=
create
(
:namespace
,
path:
'the-path'
,
parent:
parent
)
found_ids
=
subject
.
namespaces_for_paths
(
type: :
wildcar
d
).
found_ids
=
subject
.
namespaces_for_paths
(
type: :
chil
d
).
map
(
&
:id
)
expect
(
found_ids
).
to
contain_exactly
(
child
.
id
)
end
end
context
'for
wildcar
d namespaces'
do
context
'for
chil
d namespaces'
do
it
'only returns child namespaces with the correct path'
do
_root_namespace
=
create
(
:namespace
,
path:
'THE-path'
)
_other_path
=
create
(
:namespace
,
...
...
@@ -37,7 +37,7 @@ describe Gitlab::Database::RenameReservedPathsMigration::V1::RenameNamespaces do
path:
'the-path'
,
parent:
create
(
:namespace
))
found_ids
=
subject
.
namespaces_for_paths
(
type: :
wildcar
d
).
found_ids
=
subject
.
namespaces_for_paths
(
type: :
chil
d
).
map
(
&
:id
)
expect
(
found_ids
).
to
contain_exactly
(
namespace
.
id
)
end
...
...
@@ -165,7 +165,7 @@ describe Gitlab::Database::RenameReservedPathsMigration::V1::RenameNamespaces do
expect
(
subject
).
to
receive
(
:rename_namespace
).
with
(
migration_namespace
(
child_namespace
))
subject
.
rename_namespaces
(
type: :
wildcar
d
)
subject
.
rename_namespaces
(
type: :
chil
d
)
end
end
end
spec/lib/gitlab/database/rename_reserved_paths_migration_spec.rb
→
spec/lib/gitlab/database/rename_reserved_paths_migration
/v1
_spec.rb
View file @
2e2a63c8
require
'spec_helper'
describe
Gitlab
::
Database
::
RenameReservedPathsMigration
::
V1
do
let
(
:subject
)
{
FakeRenameReservedPathMigrationV1
.
new
}
before
do
allow
(
subject
).
to
receive
(
:say
)
end
describe
'#rename_wildcard_paths'
do
it
'should rename namespaces'
do
shared_examples
'renames child namespaces'
do
|
type
|
it
'renames namespaces'
do
rename_namespaces
=
double
expect
(
described_class
::
RenameNamespaces
).
to
receive
(
:new
).
with
([
'first-path'
,
'second-path'
],
subject
).
and_return
(
rename_namespaces
)
expect
(
rename_namespaces
).
to
receive
(
:rename_namespaces
).
with
(
type: :wildcar
d
)
with
(
type: :chil
d
)
subject
.
rename_wildcard_paths
([
'first-path'
,
'second-path'
])
end
end
describe
Gitlab
::
Database
::
RenameReservedPathsMigration
::
V1
do
let
(
:subject
)
{
FakeRenameReservedPathMigrationV1
.
new
}
before
do
allow
(
subject
).
to
receive
(
:say
)
end
describe
'#rename_child_paths'
do
it_behaves_like
'renames child namespaces'
end
describe
'#rename_wildcard_paths'
do
it_behaves_like
'renames child namespaces'
it
'should rename projects'
do
rename_projects
=
double
...
...
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