From 6dfab422368f54aff5f976c65e860332236bbf5c Mon Sep 17 00:00:00 2001 From: Tiago Botelho Date: Thu, 16 Aug 2018 11:02:34 +0100 Subject: [PATCH] Changes update_column to update_attributes in ProjectTreeRestorer#restore_project by using timeless to maintain the current timestamps --- ...group-visibility-error-due-to-string-conversion.yml | 6 ++++++ lib/gitlab/import_export/project_tree_restorer.rb | 5 ++++- spec/lib/gitlab/import_export/importer_spec.rb | 10 ++++++++++ 3 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 changelogs/unreleased/47765-group-visibility-error-due-to-string-conversion.yml 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