Skip to content

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

Add specs for JournableDiffer edge case when value is changed from false to nil and vice versa.

Dombi Attilaa371ddf84e02
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.rb
index 1a5a87e42a4..53b2e325b45 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,6 @@ module Acts::Journalized
def no_nil_to_empty_strings?(normalized_old_data, attribute, new_value)
old_value = normalized_old_data[attribute]
- # Checking new_value != old_value ensures that both values cannot be nil
new_value != old_value
end
diff --git a/spec/lib/acts_as_journalized/journable_differ_spec.rb b/spec/lib/acts_as_journalized/journable_differ_spec.rb
index c7f89e63cbb..1d513d407e0 100644
--- a/spec/lib/acts_as_journalized/journable_differ_spec.rb
+++ b/spec/lib/acts_as_journalized/journable_differ_spec.rb
@@ -34,7 +34,11 @@ RSpec.describe Acts::Journalized::JournableDiffer do
let(:original) do
build_stubbed(:work_package,
subject: 'The original work package title',
- description: "The description\n")
+ description: "The description\n",
+ assigned_to_id: nil,
+ schedule_manually: false,
+ ignore_non_working_days: true,
+ estimated_hours: 1)
end
let(:changed) do
build_stubbed(:work_package,
@@ -42,14 +46,20 @@ RSpec.describe Acts::Journalized::JournableDiffer do
description: "The description\r\n",
priority: original.priority,
type: original.type,
- project: original.project)
+ project: original.project,
+ schedule_manually: nil,
+ ignore_non_working_days: false,
+ estimated_hours: nil)
end
it 'returns the changes' do
expect(described_class.changes(original, changed))
.to eql("subject" => [original.subject, changed.subject],
"author_id" => [original.author_id, changed.author_id],
- "status_id" => [original.status_id, changed.status_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])
end
end
@@ -61,7 +71,10 @@ RSpec.describe Acts::Journalized::JournableDiffer do
priority_id: 5,
type_id: 89,
project_id: 12,
- status_id: 45)
+ status_id: 45,
+ schedule_manually: nil,
+ ignore_non_working_days: false,
+ estimated_hours: 1)
end
let(:changed) do
build_stubbed(:journal_work_package_journal,
@@ -70,13 +83,19 @@ RSpec.describe Acts::Journalized::JournableDiffer do
priority_id: original.priority_id,
type_id: original.type_id,
project_id: original.project_id,
- status_id: original.status_id + 12)
+ status_id: original.status_id + 12,
+ schedule_manually: false,
+ ignore_non_working_days: true,
+ estimated_hours: nil)
end
it 'returns the changes' do
expect(described_class.changes(original, changed))
.to eql("subject" => [original.subject, changed.subject],
- "status_id" => [original.status_id, changed.status_id])
+ "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])
end
end
end