summaryrefslogtreecommitdiff
path: root/spec/lib/gitlab/import_export/project_tree_restorer_spec.rb
diff options
context:
space:
mode:
authorStan Hu <stanhu@gmail.com>2019-05-22 11:29:10 -0700
committerStan Hu <stanhu@gmail.com>2019-05-22 11:32:23 -0700
commit5c8cd42bbd6a387f5e73c688615c54606810983e (patch)
tree9d4a4bdf0a16c737eb9f83645ce935ced7a11747 /spec/lib/gitlab/import_export/project_tree_restorer_spec.rb
parent20375f811a6ffa35568d70b97a3793b97231d0dd (diff)
downloadgitlab-ce-5c8cd42bbd6a387f5e73c688615c54606810983e.tar.gz
Fix invalid visibility string comparison in project import
This resolves an "ArgumentError: comparison of String with 0 failed" issue where the visibility_level is stored as a string in the project import data because the value comes directly from the Web form. This problem happened upon creating a project from a template or restoring a project. We now cast the value to an integer to guard against these kinds of failures. Closes https://gitlab.com/gitlab-org/gitlab-ce/issues/61692
Diffstat (limited to 'spec/lib/gitlab/import_export/project_tree_restorer_spec.rb')
-rw-r--r--spec/lib/gitlab/import_export/project_tree_restorer_spec.rb13
1 files changed, 13 insertions, 0 deletions
diff --git a/spec/lib/gitlab/import_export/project_tree_restorer_spec.rb b/spec/lib/gitlab/import_export/project_tree_restorer_spec.rb
index 6084dc96410..651aa600fb2 100644
--- a/spec/lib/gitlab/import_export/project_tree_restorer_spec.rb
+++ b/spec/lib/gitlab/import_export/project_tree_restorer_spec.rb
@@ -328,6 +328,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" } })