Skip to content

Commit

Permalink
Merge branch 'sh-project-import-visibility-error' into 'master'
Browse files Browse the repository at this point in the history
Fix invalid visibility string comparison in project import

Closes #61692

See merge request gitlab-org/gitlab-ce!28612
  • Loading branch information
dbalexandre committed May 22, 2019
2 parents 5431af8 + 5c8cd42 commit add00b6
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
5 changes: 5 additions & 0 deletions changelogs/unreleased/sh-project-import-visibility-error.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
title: Fix invalid visibility string comparison in project import
merge_request: 28612
author:
type: fixed
2 changes: 1 addition & 1 deletion lib/gitlab/import_export/project_tree_restorer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ def json_params

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
Expand Down
13 changes: 13 additions & 0 deletions spec/lib/gitlab/import_export/project_tree_restorer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,19 @@
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" } })

Expand Down

0 comments on commit add00b6

Please sign in to comment.