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
Handle special case of adding mulitple users to the list of shares while starting from a blankslate
Henriette Darged9104b6ec7c4
diff --git a/app/controllers/work_packages/shares_controller.rb b/app/controllers/work_packages/shares_controller.rbindex 05b7a6cca9c..d69ee61830a 100644--- a/app/controllers/work_packages/shares_controller.rb+++ b/app/controllers/work_packages/shares_controller.rb@@ -61,7 +61,9 @@ class WorkPackages::SharesController < ApplicationController@shares = overall_result.map(&:result).reverseunless overall_result.nil?- if current_visible_member_count > 1+ # In case the number of newly added shares is equal to the whole number of shares,+ # we have to render the whole modal again to get rid of the blankslate+ if current_visible_member_count > 1 && @shares.size < current_visible_member_countrespond_with_prepend_shareselserespond_with_replace_modaldiff --git a/spec/features/work_packages/share/multi_invite_spec.rb b/spec/features/work_packages/share/multi_invite_spec.rbindex fbfc8b5dbf5..095c6ac2d39 100644--- a/spec/features/work_packages/share/multi_invite_spec.rb+++ b/spec/features/work_packages/share/multi_invite_spec.rb@@ -154,6 +154,39 @@ RSpec.describe 'Work package sharing',endend+ context 'when starting with no shares yet' do+ let(:work_package) { create(:work_package, project:) }+ let(:global_manager_user) { create(:user, global_permissions: %i[manage_user create_user]) }+ let(:current_user) { global_manager_user }++ before do+ work_package_page.visit!+ click_button 'Share'+ end++ it 'allows adding multiple users and updates the modal correctly' do+ share_modal.expect_open+ share_modal.expect_blankslate++ share_modal.invite_users([not_shared_yet_with_user, another_not_shared_yet_with_user], 'Edit')++ share_modal.expect_shared_count_of(2)++ # Due to the exception of starting from a blankslate, the whole modal is re-rendered.+ # Thus the principals are sorted alphabetically, and not by the time there were added+ share_modal.expect_shared_with(not_shared_yet_with_user, 'Edit', position: 2)+ share_modal.expect_shared_with(another_not_shared_yet_with_user, 'Edit', position: 1)++ # They can be removed again+ share_modal.remove_user(not_shared_yet_with_user)+ # The additional check is needed because the second removal would otherwise be too fast for the test execution+ share_modal.expect_shared_count_of(1)++ share_modal.remove_user(another_not_shared_yet_with_user)+ share_modal.expect_blankslate+ end+ end+context 'when having global invite permission' dolet(:global_manager_user) { create(:user, global_permissions: %i[manage_user create_user]) }let(:current_user) { global_manager_user }