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
ensure journal notifications value is reset
ulferts60b4b47c7518
diff --git a/app/models/journal_manager.rb b/app/models/journal_manager.rbindex 2f540cbf10a..c6012db2699 100644--- a/app/models/journal_manager.rb+++ b/app/models/journal_manager.rb@@ -355,7 +355,7 @@ class JournalManagerself.send_notification = send_notificationsresult = block.call-+ ensureself.send_notification = old_valueresultdiff --git a/spec/models/journal_manager_spec.rb b/spec/models/journal_manager_spec.rbindex 55fe9bc710b..42b7206edd5 100644--- a/spec/models/journal_manager_spec.rb+++ b/spec/models/journal_manager_spec.rb@@ -160,4 +160,41 @@ describe JournalManager, type: :model doendendend++ describe '.with_send_notifications' do+ let!(:send_notification_before) { described_class.send_notification }+ let(:proc_called_counter) { OpenStruct.new called: false, send_notifications: !send_notification_before }+ let(:proc) { Proc.new { proc_called_counter.called = true } }++ it 'executes the block' do+ described_class.with_send_notifications !send_notification_before, &proc++ expect(proc_called_counter.called)+ .to be_truthy+ end++ it 'uses the provided send_notifications value within the proc' do+ described_class.with_send_notifications !send_notification_before, &proc++ expect(proc_called_counter.send_notifications)+ .to eql !send_notification_before+ end++ it 'resets the send_notifications to the value before' do+ described_class.with_send_notifications !send_notification_before, &proc++ expect(described_class.send_notification)+ .to eql send_notification_before+ end++ context 'with an exception being raised within the block' do+ it 'raises the exception but always resets the notification value' do+ expect { described_class.with_send_notifications(!send_notification_before) { raise ArgumentError } }+ .to raise_error ArgumentError++ expect(described_class.send_notification)+ .to eql send_notification_before+ end+ end+ endenddiff --git a/spec/models/work_package/openproject_notifications_spec.rb b/spec/models/work_package/openproject_notifications_spec.rbindex 2580e730412..0a1f7779806 100644--- a/spec/models/work_package/openproject_notifications_spec.rb+++ b/spec/models/work_package/openproject_notifications_spec.rb@@ -38,9 +38,9 @@ describe WorkPackage, type: :model dolet(:project) { FactoryBot.create :project }let(:work_package) doFactoryBot.create :work_package,- author: user,- subject: 'I can see you',- project: project+ author: user,+ subject: 'I can see you',+ project: projectendlet(:journal_ids) { [] }