diff options
author | Douwe Maan <douwe@gitlab.com> | 2018-08-31 13:11:36 +0000 |
---|---|---|
committer | Douwe Maan <douwe@gitlab.com> | 2018-08-31 13:11:36 +0000 |
commit | 472f2d566633df6c1dee1f703b06958b9a0a2cd8 (patch) | |
tree | d1cd43bb01dc89f772ea9ec622e6edffd8f45f67 | |
parent | 74c53ef6e64299fb6b2030094725a9c0265421f4 (diff) | |
parent | 6dfab422368f54aff5f976c65e860332236bbf5c (diff) | |
download | gitlab-ce-472f2d566633df6c1dee1f703b06958b9a0a2cd8.tar.gz |
Merge branch '47765-group-visibility-error-due-to-string-conversion' into 'master'
Changes update_column to update_attributes in ProjectTreeRestorer#restore_project by using timeless to maintain the current timestamps
Closes #47765
See merge request gitlab-org/gitlab-ce!21242
3 files changed, 20 insertions, 1 deletions
diff --git a/changelogs/unreleased/47765-group-visibility-error-due-to-string-conversion.yml b/changelogs/unreleased/47765-group-visibility-error-due-to-string-conversion.yml new file mode 100644 index 00000000000..ad09527b329 --- /dev/null +++ b/changelogs/unreleased/47765-group-visibility-error-due-to-string-conversion.yml @@ -0,0 +1,6 @@ +--- +title: Importing a project no longer fails when visibility level holds a string value + type +merge_request: 21242 +author: +type: fixed diff --git a/lib/gitlab/import_export/project_tree_restorer.rb b/lib/gitlab/import_export/project_tree_restorer.rb index 76b99b1de16..f4106e03a57 100644 --- a/lib/gitlab/import_export/project_tree_restorer.rb +++ b/lib/gitlab/import_export/project_tree_restorer.rb @@ -94,7 +94,10 @@ module Gitlab end def restore_project - @project.update_columns(project_params) + Gitlab::Timeless.timeless(@project) do + @project.update(project_params) + end + @project end diff --git a/spec/lib/gitlab/import_export/importer_spec.rb b/spec/lib/gitlab/import_export/importer_spec.rb index f07946824c4..8053c48ad6c 100644 --- a/spec/lib/gitlab/import_export/importer_spec.rb +++ b/spec/lib/gitlab/import_export/importer_spec.rb @@ -63,6 +63,16 @@ describe Gitlab::ImportExport::Importer do importer.execute end + + it 'sets the correct visibility_level when visibility level is a string' do + project.create_or_update_import_data( + data: { override_params: { visibility_level: Gitlab::VisibilityLevel::PRIVATE.to_s } } + ) + + importer.execute + + expect(project.visibility_level).to eq(Gitlab::VisibilityLevel::PRIVATE) + end end context 'when project successfully restored' do |