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
no mail on empty wp update
ulferts59f907560e63
diff --git a/app/models/journal.rb b/app/models/journal.rbindex 1435c8fa757..18417060ed1 100644--- a/app/models/journal.rb+++ b/app/models/journal.rb@@ -121,6 +121,10 @@ class Journal < ActiveRecord::Basepredecessorend+ def noop?+ (!notes || notes&.empty?) && get_changes.empty?+ end+privatedef save_datadiff --git a/app/models/journal/aggregated_journal.rb b/app/models/journal/aggregated_journal.rbindex 90279cd3122..83f9bece403 100644--- a/app/models/journal/aggregated_journal.rb+++ b/app/models/journal/aggregated_journal.rb@@ -346,6 +346,7 @@ class Journal::AggregatedJournal:project,:data,:data=,+ :noop?,to: :journal# Initializes a new AggregatedJournal. Allows to explicitly set a predecessor, if it is alreadydiff --git a/app/services/notifications/journal_wp_mail_service.rb b/app/services/notifications/journal_wp_mail_service.rbindex e3e6c3f7ffe..6a0f55ade25 100644--- a/app/services/notifications/journal_wp_mail_service.rb+++ b/app/services/notifications/journal_wp_mail_service.rb@@ -39,7 +39,7 @@ class Notifications::JournalWPMailServiceprivatedef journal_complete_mail(journal, send_mails)- return nil unless send_mail?(journal, send_mails)+ return nil if abort_sending?(journal, send_mails)author = User.find_by(id: journal.user_id) || DeletedUser.first@@ -129,5 +129,9 @@ class Notifications::JournalWPMailServicedef notification_enabled?(name)Setting.notified_events.include?(name)end++ def abort_sending?(journal, send_mails)+ !send_mail?(journal, send_mails) || journal.noop?+ endendenddiff --git a/lib/api/v3/activities/activity_representer.rb b/lib/api/v3/activities/activity_representer.rbindex c82e69b53c4..83bbfd9c5e5 100644--- a/lib/api/v3/activities/activity_representer.rb+++ b/lib/api/v3/activities/activity_representer.rb@@ -70,7 +70,7 @@ module APIformattable_property :notes,as: :comment,getter: ->(*) {- text = if empty?+ text = if represented.noop?"_#{I18n.t(:'journals.changes_retracted')}_"elserepresented.notes@@ -97,7 +97,7 @@ module APIdate_time_property :created_atdef _type- if empty? || represented.notes.present?+ if represented.noop? || represented.notes.present?'Activity::Comment'else'Activity'@@ -117,10 +117,6 @@ module APIdef render_details(journal, no_html: false)journal.details.map { |d| journal.render_detail(d, no_html: no_html) }end-- def empty?- represented.get_changes.empty? && represented.notes.empty?- endendendenddiff --git a/spec/services/notifications/journal_wp_mail_service_spec.rb b/spec/services/notifications/journal_wp_mail_service_spec.rbindex 847d5462b78..4c2d6dfb0bb 100644--- a/spec/services/notifications/journal_wp_mail_service_spec.rb+++ b/spec/services/notifications/journal_wp_mail_service_spec.rb@@ -333,6 +333,19 @@ describe Notifications::JournalWPMailService doit_behaves_like 'mentioned'endend++ context 'aggregated journal is empty' do+ let(:journal) { journal_2_empty_change }+ let(:journal_2_empty_change) do+ work_package.add_journal(author, 'temp')+ work_package.save(validate: false)+ work_package.journals.last.tap do |j|+ j.update_column(:notes, nil)+ end+ end++ it_behaves_like 'sends no mail'+ endenddescribe 'initialization' do