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

specify that absence of value for assocation diff returns empty string and not nil

Ivan Kuchinfd3a6acc3822
diff --git a/lib_static/plugins/acts_as_journalized/lib/acts/journalized/differ/association.rb b/lib_static/plugins/acts_as_journalized/lib/acts/journalized/differ/association.rb
index 9647d99d97e..3cb490eba91 100644
--- a/lib_static/plugins/acts_as_journalized/lib/acts/journalized/differ/association.rb
+++ b/lib_static/plugins/acts_as_journalized/lib/acts/journalized/differ/association.rb
@@ -84,6 +84,7 @@ module Acts::Journalized::Differ
end
def combine_journals(journals, attribute)
+ # TODO: is there real case where there will be more than one value?
journals.pluck(attribute).sort.join(",") if journals
end
end
diff --git a/spec/lib/acts/journalized/differ/association_spec.rb b/spec/lib/acts/journalized/differ/association_spec.rb
index 63659acf2bd..067362eb3aa 100644
--- a/spec/lib/acts/journalized/differ/association_spec.rb
+++ b/spec/lib/acts/journalized/differ/association_spec.rb
@@ -111,7 +111,9 @@ RSpec.describe Acts::Journalized::Differ::Association do
build(:journal, project_life_cycle_step_journals: [
build_stubbed(:project_life_cycle_step_journal, life_cycle_step_id: 1, active: true),
build_stubbed(:project_life_cycle_step_journal, life_cycle_step_id: 2, active: true),
- build_stubbed(:project_life_cycle_step_journal, life_cycle_step_id: 3, active: false),
+ build_stubbed(:project_life_cycle_step_journal, life_cycle_step_id: 3, active: false,
+ start_date: Date.new(2024, 1, 17),
+ end_date: Date.new(2024, 1, 18)),
build_stubbed(:project_life_cycle_step_journal, life_cycle_step_id: 4, active: true,
start_date: Date.new(2024, 1, 17),
end_date: Date.new(2024, 1, 18))
@@ -138,6 +140,8 @@ RSpec.describe Acts::Journalized::Differ::Association do
"project_life_cycle_steps_1_active" => ["false", "true"],
"project_life_cycle_steps_2_active" => [nil, "true"],
"project_life_cycle_steps_3_active" => ["true", "false"],
+ "project_life_cycle_steps_3_end_date" => ["", "2024-01-18"],
+ "project_life_cycle_steps_3_start_date" => ["", "2024-01-17"],
"project_life_cycle_steps_4_end_date" => ["2024-01-17", "2024-01-18"],
"project_life_cycle_steps_4_start_date" => ["2024-01-16", "2024-01-17"]
)
@@ -158,7 +162,11 @@ RSpec.describe Acts::Journalized::Differ::Association do
.to eq(
"project_life_cycle_steps_1" => { active: ["false", "true"] },
"project_life_cycle_steps_2" => { active: [nil, "true"] },
- "project_life_cycle_steps_3" => { active: ["true", "false"] },
+ "project_life_cycle_steps_3" => {
+ active: ["true", "false"],
+ end_date: ["", "2024-01-18"],
+ start_date: ["", "2024-01-17"]
+ },
"project_life_cycle_steps_4" => {
end_date: ["2024-01-17", "2024-01-18"],
start_date: ["2024-01-16", "2024-01-17"]