commit
7f061d3dfe
@ -0,0 +1,33 @@ |
||||
#-- encoding: UTF-8 |
||||
#-- copyright |
||||
# OpenProject is a project management system. |
||||
# Copyright (C) 2012-2014 the OpenProject Foundation (OPF) |
||||
# |
||||
# 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 doc/COPYRIGHT.rdoc for more details. |
||||
#++ |
||||
|
||||
unless OpenProject::Configuration['disabled_modules'].empty? |
||||
to_disable = OpenProject::Configuration['disabled_modules'] |
||||
OpenProject::Plugins::ModuleHandler.disable_modules(to_disable) |
||||
end |
@ -0,0 +1,50 @@ |
||||
#-- encoding: UTF-8 |
||||
#-- copyright |
||||
# OpenProject is a project management system. |
||||
# Copyright (C) 2012-2015 the OpenProject Foundation (OPF) |
||||
# |
||||
# 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 doc/COPYRIGHT.rdoc for more details. |
||||
#++ |
||||
|
||||
module API |
||||
module V3 |
||||
module Categories |
||||
class CategoriesByProjectAPI < Grape::API |
||||
resources :categories do |
||||
before do |
||||
@categories = @project.categories |
||||
end |
||||
|
||||
get do |
||||
self_link = api_v3_paths.categories(@project.identifier) |
||||
|
||||
CategoryCollectionRepresenter.new(@categories, |
||||
@categories.count, |
||||
self_link) |
||||
end |
||||
end |
||||
end |
||||
end |
||||
end |
||||
end |
@ -0,0 +1,50 @@ |
||||
#-- encoding: UTF-8 |
||||
#-- copyright |
||||
# OpenProject is a project management system. |
||||
# Copyright (C) 2012-2015 the OpenProject Foundation (OPF) |
||||
# |
||||
# 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 doc/COPYRIGHT.rdoc for more details. |
||||
#++project_module |
||||
|
||||
module OpenProject::Plugins |
||||
class ModuleHandler |
||||
@@disabled_modules = [] |
||||
|
||||
class << self |
||||
def disable_modules(module_names) |
||||
@@disabled_modules += Array(module_names).map(&:to_sym) |
||||
end |
||||
|
||||
def disable(disabled_modules) |
||||
disabled_modules.map do |module_name| |
||||
Redmine::AccessControl.remove_modules_permissions(module_name) |
||||
end |
||||
end |
||||
end |
||||
|
||||
OpenProject::Application.config.to_prepare do |
||||
OpenProject::Plugins::ModuleHandler.disable(@@disabled_modules) |
||||
end |
||||
end |
||||
end |
@ -0,0 +1,68 @@ |
||||
#-- copyright |
||||
# OpenProject is a project management system. |
||||
# Copyright (C) 2012-2015 the OpenProject Foundation (OPF) |
||||
# |
||||
# 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 doc/COPYRIGHT.rdoc for more details. |
||||
#++ |
||||
|
||||
require 'spec_helper' |
||||
|
||||
feature 'Admin menu items' do |
||||
let(:user) { FactoryGirl.create :admin } |
||||
|
||||
before do |
||||
User.stub(:current).and_return user |
||||
end |
||||
|
||||
after do |
||||
OpenProject::Configuration['hidden_menu_items'] = [] |
||||
end |
||||
|
||||
describe 'displaying all the menu items' do |
||||
it 'hides the specified admin menu items' do |
||||
visit admin_path |
||||
|
||||
expect(page).to have_selector('a', text: I18n.t('label_user_plural')) |
||||
expect(page).to have_selector('a', text: I18n.t('label_project_plural')) |
||||
expect(page).to have_selector('a', text: I18n.t('label_role_plural')) |
||||
expect(page).to have_selector('a', text: I18n.t('label_type_plural')) |
||||
end |
||||
end |
||||
|
||||
describe 'hiding menu items' do |
||||
before do |
||||
OpenProject::Configuration['hidden_menu_items'] = { 'admin_menu' => ['roles', 'types'] } |
||||
end |
||||
|
||||
it 'hides the specified admin menu items' do |
||||
visit admin_path |
||||
|
||||
expect(page).to have_selector('a', text: I18n.t('label_user_plural')) |
||||
expect(page).to have_selector('a', text: I18n.t('label_project_plural')) |
||||
|
||||
expect(page).not_to have_selector('a', text: I18n.t('label_role_plural')) |
||||
expect(page).not_to have_selector('a', text: I18n.t('label_type_plural')) |
||||
end |
||||
end |
||||
end |
@ -0,0 +1,49 @@ |
||||
#-- copyright |
||||
# OpenProject is a project management system. |
||||
# Copyright (C) 2012-2015 the OpenProject Foundation (OPF) |
||||
# |
||||
# 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 doc/COPYRIGHT.rdoc for more details. |
||||
#++ |
||||
|
||||
require 'spec_helper' |
||||
describe OpenProject::Plugins::ModuleHandler do |
||||
let!(:all_former_permissions) { Redmine::AccessControl.permissions } |
||||
|
||||
before do |
||||
disabled_modules = OpenProject::Plugins::ModuleHandler.disable_modules('repository') |
||||
OpenProject::Plugins::ModuleHandler.disable(disabled_modules) |
||||
end |
||||
|
||||
after do |
||||
raise 'Test outdated' unless Redmine::AccessControl.instance_variable_defined?(:@permissions) |
||||
Redmine::AccessControl.instance_variable_set(:@permissions, all_former_permissions) |
||||
Redmine::AccessControl.clear_caches |
||||
end |
||||
|
||||
context '#disable' do |
||||
it 'should disable repository module' do |
||||
expect(Redmine::AccessControl.available_project_modules).to_not include(:repository) |
||||
end |
||||
end |
||||
end |
@ -0,0 +1,73 @@ |
||||
#-- copyright |
||||
# OpenProject is a project management system. |
||||
# Copyright (C) 2012-2015 the OpenProject Foundation (OPF) |
||||
# |
||||
# 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 doc/COPYRIGHT.rdoc for more details. |
||||
#++ |
||||
|
||||
require 'spec_helper' |
||||
describe Redmine::AccessControl do |
||||
describe '.remove_modules_permissions' do |
||||
let!(:all_former_permissions) { Redmine::AccessControl.permissions } |
||||
let!(:former_repository_permissions) do |
||||
module_permissions = Redmine::AccessControl.modules_permissions(['repository']) |
||||
|
||||
module_permissions.select do |permission| |
||||
permission.project_module == :repository |
||||
end |
||||
end |
||||
|
||||
subject { Redmine::AccessControl } |
||||
|
||||
before do |
||||
Redmine::AccessControl.remove_modules_permissions(:repository) |
||||
end |
||||
|
||||
after do |
||||
raise 'Test outdated' unless Redmine::AccessControl.instance_variable_defined?(:@permissions) |
||||
Redmine::AccessControl.instance_variable_set(:@permissions, all_former_permissions) |
||||
Redmine::AccessControl.clear_caches |
||||
end |
||||
|
||||
it 'removes from global permissions' do |
||||
expect(subject.permissions).to_not include(former_repository_permissions) |
||||
end |
||||
|
||||
it 'removes from public permissions' do |
||||
expect(subject.public_permissions).to_not include(former_repository_permissions) |
||||
end |
||||
|
||||
it 'removes from members only permissions' do |
||||
expect(subject.members_only_permissions).to_not include(former_repository_permissions) |
||||
end |
||||
|
||||
it 'removes from loggedin only permissions' do |
||||
expect(subject.loggedin_only_permissions).to_not include(former_repository_permissions) |
||||
end |
||||
|
||||
it 'should disable repository module' do |
||||
expect(subject.available_project_modules).to_not include(:repository) |
||||
end |
||||
end |
||||
end |
Loading…
Reference in new issue