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
update spec expectation which used to be incorrect
ulferts5da326043d32
diff --git a/spec/services/notifications/mail_service_mentioned_integration_spec.rb b/spec/services/notifications/mail_service_mentioned_integration_spec.rbindex 22f04575a87..0cba2953ca5 100644--- a/spec/services/notifications/mail_service_mentioned_integration_spec.rb+++ b/spec/services/notifications/mail_service_mentioned_integration_spec.rb@@ -32,49 +32,80 @@ require_relative './mentioned_journals_shared'describe Notifications::MailService, 'Mentioned integration', type: :model doinclude_context 'with a mentioned work package being updated again'+ let(:assignee) do+ create :user,+ preferences: {+ immediate_reminders: {+ mentioned: true+ }+ },+ notification_settings: [+ build(:notification_setting,+ mentioned: true,+ involved: true)+ ],+ member_in_project: project,+ member_through_role: role+ end++ let(:assigned_notification) do+ Notification.find_by(recipient: assignee, journal: work_package.journals.last, reason: :assigned)+ end+def expect_mentioned_notificationexpect(mentioned_notification).to be_present+ mentioned_notification.reload+ expect(mentioned_notification.recipient).to eq recipientexpect(mentioned_notification.reason).to eq 'mentioned'expect(mentioned_notification.read_ian).to be falseexpect(mentioned_notification.mail_alert_sent).to be trueend- def expect_mentioned_notification_updated- old_journal_id = mentioned_notification.journal_id- mentioned_notification.reload- expect(mentioned_notification.journal_id).not_to eq old_journal_id- expect(mentioned_notification.journal).to eq work_package.journals.last- expect(mentioned_notification.reason).to eq 'mentioned'- expect(mentioned_notification.read_ian).to be false- expect(mentioned_notification.mail_alert_sent).to be true+ def expect_no_assigned_notification+ expect(Notification.where(recipient:, resource: work_package, reason: :involved))+ .to be_emptyenddef expect_assigned_notificationexpect(assigned_notification).to be_present+ expect(assigned_notification.recipient).to eq assigneeexpect(assigned_notification.read_ian).to be falseexpect(assigned_notification.mail_alert_sent).to be falseendit 'will trigger only one mention notification mail when editing attributes afterwards' doallow(WorkPackageMailer)- .to(receive(:mentioned))- .and_call_original+ .to receive(:mentioned)+ .and_call_originaltrigger_comment!expect(WorkPackageMailer).to have_received(:mentioned)- .with(recipient, work_package.journals.last)+ .with(recipient, work_package.journals.last)+ .once++ expect_mentioned_notification++ update_assignee!(recipient)++ # No mailing is to be added but the mailing from before still counts.+ expect(WorkPackageMailer)+ .to have_received(:mentioned)+ .once+ # No involved notification since the assignee is also mentioned which trumps+ # being assignee and a user will only get one notification for a journal.+ expect_no_assigned_notificationexpect_mentioned_notification- update_assignee!+ update_assignee!(assignee)+ # No mailing is to be added but the mailing from before still counts.expect(WorkPackageMailer)- .not_to have_received(:mentioned)- .with(recipient, work_package.journals.last)+ .to have_received(:mentioned)+ .once- expect_mentioned_notification_updatedexpect_assigned_notificationendenddiff --git a/spec/services/notifications/mentioned_journals_shared.rb b/spec/services/notifications/mentioned_journals_shared.rbindex a8af74844ab..86f19c18a7d 100644--- a/spec/services/notifications/mentioned_journals_shared.rb+++ b/spec/services/notifications/mentioned_journals_shared.rb@@ -73,10 +73,6 @@ shared_context 'with a mentioned work package being updated again' doNotification.find_by(recipient:, journal: work_package.journals.last, reason: :mentioned)end- let(:assigned_notification) do- Notification.find_by(recipient:, journal: work_package.journals.last, reason: :assigned)- end-def trigger_comment!User.execute_as(actor) dowork_package.journal_notes = comment@@ -87,11 +83,11 @@ shared_context 'with a mentioned work package being updated again' dowork_package.reloadend- def update_assignee!+ def update_assignee!(assignee_user = recipient)clear_enqueued_jobsUser.execute_as(actor) do- work_package.assigned_to = recipient+ work_package.assigned_to = assignee_userwork_package.save!end