Allow project feature permissions to be overridden during import

This commit is contained in:
George Koltsov 2019-08-29 16:49:22 +00:00 committed by Rémy Coutable
parent de651ce802
commit 34d142e593
3 changed files with 28 additions and 0 deletions

View File

@ -61,6 +61,8 @@ class Project < ApplicationRecord
delegate :feature_available?, :builds_enabled?, :wiki_enabled?,
:merge_requests_enabled?, :issues_enabled?, :pages_enabled?, :public_pages?,
:merge_requests_access_level, :issues_access_level, :wiki_access_level,
:snippets_access_level, :builds_access_level, :repository_access_level,
to: :project_feature, allow_nil: true
delegate :base_dir, :disk_path, :ensure_storage_path_exists, to: :storage

View File

@ -0,0 +1,5 @@
---
title: Allow project feature permissions to be overridden during import with override_params
merge_request: 32348
author:
type: fixed

View File

@ -396,6 +396,27 @@ describe Gitlab::ImportExport::ProjectTreeRestorer do
expect(project.lfs_enabled).to be_falsey
end
it 'overrides project feature access levels' do
access_level_keys = project.project_feature.attributes.keys.select { |a| a =~ /_access_level/ }
# `pages_access_level` is not included, since it is not available in the public API
# and has a dependency on project's visibility level
# see ProjectFeature model
access_level_keys.delete('pages_access_level')
disabled_access_levels = Hash[access_level_keys.collect { |item| [item, 'disabled'] }]
project.create_import_data(data: { override_params: disabled_access_levels })
restored_project_json
aggregate_failures do
access_level_keys.each do |key|
expect(project.public_send(key)).to eq(ProjectFeature::DISABLED)
end
end
end
end
context 'with a project that has a group' do