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
385468e0
Commit
385468e0
authored
Dec 13, 2019
by
nmilojevic1
Committed by
Stan Hu
Dec 17, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix MR comments
- Added author column inside Where - Made configuration_helper more generalised
parent
0fac0300
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
14 additions
and
12 deletions
+14
-12
spec/lib/gitlab/import_export/attribute_configuration_spec.rb
.../lib/gitlab/import_export/attribute_configuration_spec.rb
+1
-1
spec/lib/gitlab/import_export/model_configuration_spec.rb
spec/lib/gitlab/import_export/model_configuration_spec.rb
+1
-1
spec/lib/gitlab/import_export/references_configuration_spec.rb
...lib/gitlab/import_export/references_configuration_spec.rb
+5
-3
spec/support/import_export/configuration_helper.rb
spec/support/import_export/configuration_helper.rb
+7
-7
No files found.
spec/lib/gitlab/import_export/attribute_configuration_spec.rb
View file @
385468e0
...
@@ -16,7 +16,7 @@ describe 'Import/Export attribute configuration' do
...
@@ -16,7 +16,7 @@ describe 'Import/Export attribute configuration' do
let
(
:safe_model_attributes
)
{
YAML
.
load_file
(
safe_attributes_file
)
}
let
(
:safe_model_attributes
)
{
YAML
.
load_file
(
safe_attributes_file
)
}
it
'has no new columns'
do
it
'has no new columns'
do
project_relation_names
.
each
do
|
relation_name
|
relation_names_for
(
:project
)
.
each
do
|
relation_name
|
relation_class
=
relation_class_for_name
(
relation_name
)
relation_class
=
relation_class_for_name
(
relation_name
)
relation_attributes
=
relation_class
.
new
.
attributes
.
keys
-
relation_class
.
encrypted_attributes
.
keys
.
map
(
&
:to_s
)
relation_attributes
=
relation_class
.
new
.
attributes
.
keys
-
relation_class
.
encrypted_attributes
.
keys
.
map
(
&
:to_s
)
...
...
spec/lib/gitlab/import_export/model_configuration_spec.rb
View file @
385468e0
...
@@ -11,7 +11,7 @@ describe 'Import/Export model configuration' do
...
@@ -11,7 +11,7 @@ describe 'Import/Export model configuration' do
let
(
:all_models_yml
)
{
'spec/lib/gitlab/import_export/all_models.yml'
}
let
(
:all_models_yml
)
{
'spec/lib/gitlab/import_export/all_models.yml'
}
let
(
:all_models_hash
)
{
YAML
.
load_file
(
all_models_yml
)
}
let
(
:all_models_hash
)
{
YAML
.
load_file
(
all_models_yml
)
}
let
(
:current_models
)
{
setup_models
}
let
(
:current_models
)
{
setup_models
}
let
(
:model_names
)
{
project_relation_names
}
let
(
:model_names
)
{
relation_names_for
(
:project
)
}
it
'has no new models'
do
it
'has no new models'
do
model_names
.
each
do
|
model_name
|
model_names
.
each
do
|
model_name
|
...
...
spec/lib/gitlab/import_export/references_configuration_spec.rb
View file @
385468e0
...
@@ -13,12 +13,14 @@ describe 'Import/Export Project configuration' do
...
@@ -13,12 +13,14 @@ describe 'Import/Export Project configuration' do
include
ConfigurationHelper
include
ConfigurationHelper
where
(
:relation_path
,
:relation_name
)
do
where
(
:relation_path
,
:relation_name
)
do
project_relation_paths
.
map
{
|
a
|
[
a
.
join
(
"."
),
a
.
last
]}
relation_paths_for
(
:project
).
map
do
|
relation_names
|
next
if
relation_names
.
last
==
"author"
[
relation_names
.
join
(
"."
),
relation_names
.
last
]
end
.
compact
end
end
with_them
do
with_them
do
next
if
params
[
:relation_name
]
==
"author"
context
"where relation
#{
params
[
:relation_path
]
}
"
do
context
"where relation
#{
params
[
:relation_path
]
}
"
do
it
'does not have prohibited keys'
do
it
'does not have prohibited keys'
do
relation_class
=
relation_class_for_name
(
relation_name
)
relation_class
=
relation_class_for_name
(
relation_name
)
...
...
spec/support/import_export/configuration_helper.rb
View file @
385468e0
...
@@ -22,22 +22,22 @@ module ConfigurationHelper
...
@@ -22,22 +22,22 @@ module ConfigurationHelper
new_hash
new_hash
end
end
def
config_hash
def
config_hash
(
config
=
Gitlab
::
ImportExport
.
config_file
)
Gitlab
::
ImportExport
::
Config
.
new
.
to_h
.
deep_stringify_keys
Gitlab
::
ImportExport
::
Config
.
new
(
config:
config
)
.
to_h
.
deep_stringify_keys
end
end
def
project_relation_paths
def
relation_paths_for
(
key
,
config:
Gitlab
::
ImportExport
.
config_file
)
# - project is not part of the tree, so it has to be added manually.
# - project is not part of the tree, so it has to be added manually.
flat_hash
({
"project"
=>
config_hash
.
dig
(
'tree'
,
'project'
)
}).
keys
flat_hash
({
"project"
=>
config_hash
(
config
).
dig
(
'tree'
,
key
.
to_s
)
}).
keys
end
end
def
project_relation_names
def
relation_names_for
(
key
,
config:
Gitlab
::
ImportExport
.
config_file
)
names
=
names_from_tree
(
config_hash
.
dig
(
'tree'
,
'project'
))
names
=
names_from_tree
(
config_hash
(
config
).
dig
(
'tree'
,
key
.
to_s
))
# Remove duplicated or add missing models
# Remove duplicated or add missing models
# - project is not part of the tree, so it has to be added manually.
# - project is not part of the tree, so it has to be added manually.
# - milestone, labels, merge_request have both singular and plural versions in the tree, so remove the duplicates.
# - milestone, labels, merge_request have both singular and plural versions in the tree, so remove the duplicates.
# - User, Author... Models we do not care about for checking models
# - User, Author... Models we do not care about for checking models
names
.
flatten
.
uniq
-
%w(milestones labels user author merge_request design)
+
[
'project'
]
names
.
flatten
.
uniq
-
%w(milestones labels user author merge_request design)
+
[
key
.
to_s
]
end
end
def
relation_class_for_name
(
relation_name
)
def
relation_class_for_name
(
relation_name
)
...
...
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