Skip to content

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

[#52448] Disable work package module does not work

Pavel Balashoub8874bf23522
diff --git a/config/initializers/menus.rb b/config/initializers/menus.rb
index 38754ce62af..fdd25575784 100644
--- a/config/initializers/menus.rb
+++ b/config/initializers/menus.rb
@@ -546,6 +546,7 @@ Redmine::MenuManager.map :project_menu do |menu|
menu.push :work_packages,
{ controller: '/work_packages', action: 'index' },
caption: :label_work_package_plural,
+ if: Proc.new { |p| p.module_enabled?('work_package_tracking') },
icon: 'view-list',
html: {
id: 'main-menu-work-packages',
diff --git a/spec/features/projects/modules_spec.rb b/spec/features/projects/modules_spec.rb
index 81a76efc5f3..b3cd16bb194 100644
--- a/spec/features/projects/modules_spec.rb
+++ b/spec/features/projects/modules_spec.rb
@@ -30,11 +30,10 @@ require 'spec_helper'
RSpec.describe 'Projects module administration' do
let!(:project) do
- create(:project,
- enabled_module_names: [])
+ create(:project, enabled_module_names: [])
end
- let(:permissions) { %i(edit_project select_project_modules) }
+ let(:permissions) { %i(edit_project select_project_modules view view_work_packages) }
let(:settings_page) { Pages::Projects::Settings.new(project) }
current_user do
@@ -42,31 +41,25 @@ RSpec.describe 'Projects module administration' do
end
it 'allows adding and removing modules' do
+ project_work_packages_menu_link_selector = '//ul[contains(@class, "menu_root")]//span[text()="Work packages"]'
+
settings_page.visit_tab!('modules')
- expect(page)
- .to have_unchecked_field 'Activity'
+ expect(page).to have_unchecked_field 'Activity'
+ expect(page).to have_unchecked_field 'Work packages'
+ expect(page).to have_unchecked_field 'Calendar'
+ expect(page).to have_unchecked_field 'Time and costs'
- expect(page)
- .to have_unchecked_field 'Calendar'
-
- expect(page)
- .to have_unchecked_field 'Time and costs'
+ expect(page).not_to have_xpath(project_work_packages_menu_link_selector, visible: false)
check 'Activity'
-
click_button 'Save'
settings_page.expect_toast message: I18n.t(:notice_successful_update)
- expect(page)
- .to have_checked_field 'Activity'
-
- expect(page)
- .to have_unchecked_field 'Calendar'
-
- expect(page)
- .to have_unchecked_field 'Time and costs'
+ expect(page).to have_checked_field 'Activity'
+ expect(page).to have_unchecked_field 'Calendar'
+ expect(page).to have_unchecked_field 'Time and costs'
check 'Calendar'
@@ -78,20 +71,22 @@ RSpec.describe 'Projects module administration' do
dependency: 'Work packages',
module: 'Calendars')
+ expect(page).not_to have_xpath(project_work_packages_menu_link_selector, visible: false)
check 'Work packages'
-
click_button 'Save'
settings_page.expect_toast message: I18n.t(:notice_successful_update)
- expect(page)
- .to have_checked_field 'Activity'
+ expect(page).to have_checked_field 'Activity'
+ expect(page).to have_checked_field 'Calendars'
+ expect(page).to have_checked_field 'Work packages'
- expect(page)
- .to have_checked_field 'Calendars'
+ expect(page).to have_xpath(project_work_packages_menu_link_selector, visible: false)
- expect(page)
- .to have_checked_field 'Work packages'
+ uncheck 'Work packages'
+ click_button 'Save'
+
+ expect(page).not_to have_xpath(project_work_packages_menu_link_selector, visible: false)
end
context 'with a user who does not have the correct permissions (#38097)' do
@@ -106,8 +101,7 @@ RSpec.describe 'Projects module administration' do
end
it "I can't see the modules menu item" do
- expect(page)
- .to have_no_css('[data-name="settings_modules"]')
+ expect(page).to have_no_css('[data-name="settings_modules"]')
end
end
end