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
Refactor added specs
Dombi Attila897e9f77d0c7
diff --git a/spec/services/projects/copy_service_integration_spec.rb b/spec/services/projects/copy_service_integration_spec.rbindex 0bd3ef4d4ef..1adbba45c2c 100644--- a/spec/services/projects/copy_service_integration_spec.rb+++ b/spec/services/projects/copy_service_integration_spec.rb@@ -650,22 +650,54 @@ RSpec.describe(let(:only_args) { %w[work_packages work_package_shares] }- it "copies the shared with membership for the work package" do- expect(subject).to be_success- expect(project_copy.members.count).to eq 2+ shared_examples "does not sends share notification" do+ it "does not create any notifications" do+ subject+ # The sharee is not notified+ expect { perform_enqueued_jobs }+ .not_to change(Notification.where(recipient: source_wp_shared_with_user), :count)+ end+ end- shared_wp_member = project_copy.members.find_by(entity_type: "WorkPackage")- expect(shared_wp_member.principal).to eq(source_wp_shared_with_user)- expect(shared_wp_member.roles).to contain_exactly(wp_role)+ shared_examples "sends share notification" do+ it "creates a notification for the sharee" do+ subject+ # The sharee of the new work package receives a notification+ expect { perform_enqueued_jobs }+ .to change(Notification.where(recipient: source_wp_shared_with_user), :count)+ .from(0)+ .to(1)+ end+ end- copied_wp = project_copy.work_packages.find_by(subject: "source wp")- expect(shared_wp_member.entity).to eq(copied_wp)+ shared_examples "copies the shared with membership for the work package" do+ it "copies the shared with membership for the work package" do+ expect(subject).to be_success+ expect(project_copy.members.count).to eq 2++ shared_wp_member = project_copy.members.find_by(entity_type: "WorkPackage")+ expect(shared_wp_member.principal).to eq(source_wp_shared_with_user)+ expect(shared_wp_member.roles).to contain_exactly(wp_role)++ copied_wp = project_copy.work_packages.find_by(subject: "source wp")+ expect(shared_wp_member.entity).to eq(copied_wp)+ end+ end++ it_behaves_like "copies the shared with membership for the work package"+ it_behaves_like "sends share notification"++ context "when send_notifications are disabled" do+ let(:send_notifications) { false }++ it_behaves_like "copies the shared with membership for the work package"+ it_behaves_like "does not sends share notification"endcontext "having disabled" dolet(:only_args) { %w[work_packages] }- it "copies the standard membership for the work package" do+ it "copies the standard membership for the project only" doexpect(subject).to be_successexpect(project_copy.members.count).to eq 1@@ -673,6 +705,8 @@ RSpec.describe(expect(wp_member.principal).to eq(current_user)expect(wp_member).to be_project_roleend++ it_behaves_like "does not sends share notification"endend