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
Filter out the nil to empty string attribute changes in the JournableDiffer.
Dombi Attila953bdf0f2ddf
diff --git a/lib_static/plugins/acts_as_journalized/lib/acts/journalized/journable_differ.rb b/lib_static/plugins/acts_as_journalized/lib/acts/journalized/journable_differ.rbindex 53b2e325b45..fbfe65915b8 100644--- a/lib_static/plugins/acts_as_journalized/lib/acts/journalized/journable_differ.rb+++ b/lib_static/plugins/acts_as_journalized/lib/acts/journalized/journable_differ.rb@@ -52,7 +52,7 @@ module Acts::Journalizeddef no_nil_to_empty_strings?(normalized_old_data, attribute, new_value)old_value = normalized_old_data[attribute]- new_value != old_value+ new_value != old_value && ([new_value, old_value] - ['', nil]).present?enddef journaled_attributes(object)diff --git a/spec/lib/acts_as_journalized/journable_differ_spec.rb b/spec/lib/acts_as_journalized/journable_differ_spec.rbindex 1d513d407e0..8f84fd58738 100644--- a/spec/lib/acts_as_journalized/journable_differ_spec.rb+++ b/spec/lib/acts_as_journalized/journable_differ_spec.rb@@ -57,9 +57,9 @@ RSpec.describe Acts::Journalized::JournableDiffer do.to eql("subject" => [original.subject, changed.subject],"author_id" => [original.author_id, changed.author_id],"status_id" => [original.status_id, changed.status_id],- "schedule_manually" => [original.schedule_manually, nil],- "ignore_non_working_days" => [original.ignore_non_working_days, changed.ignore_non_working_days],- "estimated_hours" => [original.estimated_hours, nil])+ "schedule_manually" => [false, nil],+ "ignore_non_working_days" => [true, false],+ "estimated_hours" => [1.0, nil])endend@@ -67,7 +67,7 @@ RSpec.describe Acts::Journalized::JournableDiffer dolet(:original) dobuild_stubbed(:journal_work_package_journal,subject: 'The original work package title',- description: "The description\n",+ description: nil,priority_id: 5,type_id: 89,project_id: 12,@@ -79,7 +79,7 @@ RSpec.describe Acts::Journalized::JournableDiffer dolet(:changed) dobuild_stubbed(:journal_work_package_journal,subject: 'The changed work package title',- description: "The description\r\n",+ description: '',priority_id: original.priority_id,type_id: original.type_id,project_id: original.project_id,@@ -90,12 +90,14 @@ RSpec.describe Acts::Journalized::JournableDiffer doendit 'returns the changes' do+ # The description field changes from nil to '', but we want filter those transitions out,+ # hence the expected hash does not contain the description related change.expect(described_class.changes(original, changed)).to eql("subject" => [original.subject, changed.subject],"status_id" => [original.status_id, changed.status_id],- "schedule_manually" => [nil, changed.schedule_manually],- "ignore_non_working_days" => [original.ignore_non_working_days, changed.ignore_non_working_days],- "estimated_hours" => [original.estimated_hours, nil])+ "schedule_manually" => [nil, false],+ "ignore_non_working_days" => [false, true],+ "estimated_hours" => [1.0, nil])endendend