Skip to content

Commit

Permalink
Merge pull request #14815 from opf/bug/52448-disable-work-package-mod…
Browse files Browse the repository at this point in the history
…ule-does-not-work

[#52448] Disable work package module does not work
  • Loading branch information
ba1ash authored Feb 20, 2024
2 parents fa5e24b + 1b6b23a commit 747d495
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 29 deletions.
1 change: 1 addition & 0 deletions config/initializers/menus.rb
Original file line number Diff line number Diff line change
Expand Up @@ -546,6 +546,7 @@
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',
Expand Down
54 changes: 25 additions & 29 deletions spec/features/projects/modules_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,46 +30,39 @@

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_work_packages) }
let(:settings_page) { Pages::Projects::Settings.new(project) }

current_user do
create(:user, member_with_permissions: { project => permissions })
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 'Calendar'
expect(page).to have_unchecked_field 'Time and costs'
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).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'
expect(page).to have_unchecked_field 'Work packages'

check 'Calendar'

click_button 'Save'

expect(page)
Expand All @@ -78,20 +71,24 @@
dependency: 'Work packages',
module: 'Calendars')

check 'Work packages'
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_unchecked_field 'Time and costs'
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
Expand All @@ -106,8 +103,7 @@
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

0 comments on commit 747d495

Please sign in to comment.