diff options
author | James Lopez <james@jameslopez.es> | 2016-09-26 11:32:26 +0200 |
---|---|---|
committer | James Lopez <james@jameslopez.es> | 2016-09-27 14:56:33 +0200 |
commit | fc548207d5717f0d54840a8d2d79a2fe15e86c82 (patch) | |
tree | 5cdfc3fe22a38b5b347681c977ef2fd8cae2e140 /lib | |
parent | 7b42ff6306bccc63a70f6731ce92974ec0a5e12b (diff) | |
download | gitlab-ce-fc548207d5717f0d54840a8d2d79a2fe15e86c82.tar.gz |
fix model order in import/export config and 1to1 relation issue. Added relevant specs.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/gitlab/import_export/import_export.yml | 6 | ||||
-rw-r--r-- | lib/gitlab/import_export/project_tree_restorer.rb | 8 |
2 files changed, 10 insertions, 4 deletions
diff --git a/lib/gitlab/import_export/import_export.yml b/lib/gitlab/import_export/import_export.yml index 1c42acab9c1..bb9d1080330 100644 --- a/lib/gitlab/import_export/import_export.yml +++ b/lib/gitlab/import_export/import_export.yml @@ -1,5 +1,8 @@ # Model relationships to be included in the project import/export project_tree: + - :labels + - milestones: + - :events - issues: - :events - notes: @@ -39,9 +42,6 @@ project_tree: - protected_branches: - :merge_access_levels - :push_access_levels - - :labels - - milestones: - - :events - :project_feature # Only include the following attributes for the models specified. diff --git a/lib/gitlab/import_export/project_tree_restorer.rb b/lib/gitlab/import_export/project_tree_restorer.rb index c7b3551b84c..35ff134ea19 100644 --- a/lib/gitlab/import_export/project_tree_restorer.rb +++ b/lib/gitlab/import_export/project_tree_restorer.rb @@ -61,11 +61,17 @@ module Gitlab def restore_project return @project unless @tree_hash - project_params = @tree_hash.reject { |_key, value| value.is_a?(Array) } @project.update(project_params) @project end + def project_params + @tree_hash.reject do |key, value| + # return params that are not 1 to many or 1 to 1 relations + value.is_a?(Array) || key == key.singularize + end + end + # Given a relation hash containing one or more models and its relationships, # loops through each model and each object from a model type and # and assigns its correspondent attributes hash from +tree_hash+ |