Commit a9013d2e authored by Douglas Barbosa Alexandre's avatar Douglas Barbosa Alexandre Committed by GitLab Release Tools Bot

Merge branch 'sh-project-import-visibility-error' into 'master'

Fix invalid visibility string comparison in project import

Closes #61692

See merge request gitlab-org/gitlab-ce!28612

(cherry picked from commit add00b69)

5c8cd42b Fix invalid visibility string comparison in project import
parent 7e47a8e6
---
title: Fix invalid visibility string comparison in project import
merge_request: 28612
author:
type: fixed
......@@ -129,7 +129,7 @@ module Gitlab
def visibility_level
level = override_params['visibility_level'] || json_params['visibility_level'] || @project.visibility_level
level = @project.group.visibility_level if @project.group && level > @project.group.visibility_level
level = @project.group.visibility_level if @project.group && level.to_i > @project.group.visibility_level
{ 'visibility_level' => level }
end
......
......@@ -348,6 +348,19 @@ describe Gitlab::ImportExport::ProjectTreeRestorer do
end
context 'when the project has overridden params in import data' do
it 'handles string versions of visibility_level' do
# Project needs to be in a group for visibility level comparison
# to happen
group = create(:group)
project.group = group
project.create_import_data(data: { override_params: { visibility_level: Gitlab::VisibilityLevel::INTERNAL.to_s } })
restored_project_json
expect(project.visibility_level).to eq(Gitlab::VisibilityLevel::INTERNAL)
end
it 'overwrites the params stored in the JSON' do
project.create_import_data(data: { override_params: { description: "Overridden" } })
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment