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
rely on caller to reset the journal notification setting
ulferts2ed7a6994303
diff --git a/app/models/journal/notification_configuration.rb b/app/models/journal/notification_configuration.rbindex 3a5946bc918..6d36b33fb9a 100644--- a/app/models/journal/notification_configuration.rb+++ b/app/models/journal/notification_configuration.rb@@ -30,12 +30,6 @@class Journal::NotificationConfigurationclass << self- attr_reader :active-- def reset- self.active = true- end-def with(send_notifications, &block)old_value = active@@ -46,15 +40,13 @@ class Journal::NotificationConfigurationself.active = old_valueend- def with_reset(&block)- block.call- ensure- reset+ def active?+ activeendprotected- attr_writer :active+ attr_accessor :activeendself.active = truediff --git a/lib/plugins/acts_as_journalized/lib/redmine/acts/journalized/save_hooks.rb b/lib/plugins/acts_as_journalized/lib/redmine/acts/journalized/save_hooks.rbindex 03bd529099c..ccd751837fb 100644--- a/lib/plugins/acts_as_journalized/lib/redmine/acts/journalized/save_hooks.rb+++ b/lib/plugins/acts_as_journalized/lib/redmine/acts/journalized/save_hooks.rb@@ -69,7 +69,7 @@ module Redmine::Acts::Journalizedenddef save_journals- with_journal_attributes_and_notification_reset do+ with_ensured_journal_attributes doadd_journal = journals.empty? || JournalManager.changed?(self) || !@journal_notes.empty?if add_journal@@ -77,7 +77,7 @@ module Redmine::Acts::JournalizedOpenProject::Notifications.send('journal_created',journal: journal,- send_notification: Journal::NotificationConfiguration.active)+ send_notification: Journal::NotificationConfiguration.active?)endend@@ -90,15 +90,6 @@ module Redmine::Acts::Journalizedprivate- def with_journal_attributes_and_notification_reset- with_ensured_journal_attributes do- # Need to clear the notification setting after each usage otherwise it might be cached- Journal::NotificationConfiguration.with_reset do- yield- end- end- end-def with_ensured_journal_attributes@journal_user ||= User.current@journal_notes ||= ''diff --git a/spec/models/journal/notification_configuration_spec.rb b/spec/models/journal/notification_configuration_spec.rbindex d34a952aee5..6a47ebf47db 100644--- a/spec/models/journal/notification_configuration_spec.rb+++ b/spec/models/journal/notification_configuration_spec.rb@@ -30,7 +30,7 @@ require 'spec_helper'describe Journal::NotificationConfiguration, type: :model dodescribe '.with' do- let!(:send_notification_before) { described_class.active }+ let!(:send_notification_before) { described_class.active? }let(:proc_called_counter) { OpenStruct.new called: false, send_notifications: !send_notification_before }let(:proc) { Proc.new { proc_called_counter.called = true } }@@ -51,7 +51,7 @@ describe Journal::NotificationConfiguration, type: :model doit 'resets the send_notifications to the value before' dodescribed_class.with !send_notification_before, &proc- expect(described_class.active)+ expect(described_class.active?).to eql send_notification_beforeend@@ -60,7 +60,7 @@ describe Journal::NotificationConfiguration, type: :model doexpect { described_class.with(!send_notification_before) { raise ArgumentError } }.to raise_error ArgumentError- expect(described_class.active)+ expect(described_class.active?).to eql send_notification_beforeendend