OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
Seed storages permissions
Wieland Lindenthalee4b50995dbb
diff --git a/modules/storage/spec/seeders/seeder_spec.rb b/modules/storage/spec/seeders/seeder_spec.rbnew file mode 100644index 00000000000..1b6c455f01f--- /dev/null+++ b/modules/storage/spec/seeders/seeder_spec.rb@@ -0,0 +1,40 @@+#-- copyright+# OpenProject is an open source project management software.+# Copyright (C) 2012-2022 the OpenProject GmbH+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License version 3.+#+# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:+# Copyright (C) 2006-2013 Jean-Philippe Lang+# Copyright (C) 2010-2013 the ChiliProject Team+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License+# as published by the Free Software Foundation; either version 2+# of the License, or (at your option) any later version.+#+# This program is distributed in the hope that it will be useful,+# but WITHOUT ANY WARRANTY; without even the implied warranty of+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+# GNU General Public License for more details.+#+# You should have received a copy of the GNU General Public License+# along with this program; if not, write to the Free Software+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.+#+# See COPYRIGHT and LICENSE files for more details.+#++++require 'spec_helper'++describe RootSeeder,+ 'Storage module' do+ it 'seeds role permissions for Storages' do+ expect { described_class.new.do_seed! }.not_to raise_error++ expect(RolePermission.where(permission: :view_file_links).count).to eq 5+ expect(RolePermission.where(permission: :manage_file_links).count).to eq 2+ expect(RolePermission.where(permission: :manage_storages_in_project).count).to eq 1+ end+enddiff --git a/modules/storages/lib/open_project/storages/engine.rb b/modules/storages/lib/open_project/storages/engine.rbindex 9a3c5e7e54a..30d2ba02aaf 100644--- a/modules/storages/lib/open_project/storages/engine.rb+++ b/modules/storages/lib/open_project/storages/engine.rb@@ -79,6 +79,8 @@ module OpenProject::Storagesparent: :settingsend+ patch_with_namespace :BasicData, :RoleSeeder+# This hook is executed when the module is loaded.config.to_prepare do# We have a bunch of filters defined within the module. Here we register the filters.diff --git a/modules/storages/lib/open_project/storages/patches/role_seeder_patch.rb b/modules/storages/lib/open_project/storages/patches/role_seeder_patch.rbnew file mode 100644index 00000000000..e5d9d7ff5ec--- /dev/null+++ b/modules/storages/lib/open_project/storages/patches/role_seeder_patch.rb@@ -0,0 +1,31 @@+module OpenProject::Storages::Patches::RoleSeederPatch+ def self.included(base) # :nodoc:+ base.prepend InstanceMethods+ end++ module InstanceMethods+ def member+ role_data = super+ role_data[:permissions] += %i[view_file_links manage_file_links]+ role_data+ end++ def reader+ role_data = super+ role_data[:permissions] += %i[view_file_links]+ role_data+ end++ def non_member+ role_data = super+ role_data[:permissions] += %i[view_file_links]+ role_data+ end++ def anonymous+ role_data = super+ role_data[:permissions] += %i[view_file_links]+ role_data+ end+ end+end