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

remove grouping option for multiple_attributes_changes

Ivan Kuchin718648c5aa3d
diff --git a/app/models/journal.rb b/app/models/journal.rb
index 7c88ba7a4c0..22478e5b314 100644
--- a/app/models/journal.rb
+++ b/app/models/journal.rb
@@ -50,7 +50,8 @@ class Journal < ApplicationRecord
register_journal_formatter OpenProject::JournalFormatter::MeetingStartTime
register_journal_formatter OpenProject::JournalFormatter::MeetingState
register_journal_formatter OpenProject::JournalFormatter::MeetingWorkPackageId
- register_journal_formatter OpenProject::JournalFormatter::ProjectLifeCycleStep
+ register_journal_formatter OpenProject::JournalFormatter::ProjectLifeCycleStepActive
+ register_journal_formatter OpenProject::JournalFormatter::ProjectLifeCycleStepDates
register_journal_formatter OpenProject::JournalFormatter::ProjectStatusCode
register_journal_formatter OpenProject::JournalFormatter::ScheduleManually
register_journal_formatter OpenProject::JournalFormatter::SubprojectNamedAssociation
diff --git a/app/models/project.rb b/app/models/project.rb
index 63df3d59377..f368c165fa2 100644
--- a/app/models/project.rb
+++ b/app/models/project.rb
@@ -146,7 +146,8 @@ class Project < ApplicationRecord
register_journal_formatted_fields "public", formatter_key: :visibility
register_journal_formatted_fields "parent_id", formatter_key: :subproject_named_association
register_journal_formatted_fields /custom_fields_\d+/, formatter_key: :custom_field
- register_journal_formatted_fields /^project_life_cycle_step_\d+$/, formatter_key: :project_life_cycle_step
+ register_journal_formatted_fields /^project_life_cycle_step_\d+_active$/, formatter_key: :project_life_cycle_step_active
+ register_journal_formatted_fields /^project_life_cycle_step_\d+_date_range$/, formatter_key: :project_life_cycle_step_dates
has_paper_trail
diff --git a/lib/open_project/journal_formatter/project_life_cycle_step_active.rb b/lib/open_project/journal_formatter/project_life_cycle_step_active.rb
new file mode 100644
index 00000000000..22e937b94e2
--- /dev/null
+++ b/lib/open_project/journal_formatter/project_life_cycle_step_active.rb
@@ -0,0 +1,52 @@
+# frozen_string_literal: true
+
+#-- copyright
+# OpenProject is an open source project management software.
+# Copyright (C) the OpenProject GmbH
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License version 3.
+#
+# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
+# Copyright (C) 2006-2013 Jean-Philippe Lang
+# Copyright (C) 2010-2013 the ChiliProject Team
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+#
+# See COPYRIGHT and LICENSE files for more details.
+#++
+
+class OpenProject::JournalFormatter::ProjectLifeCycleStepActive < JournalFormatter::Base
+ def render(key, values, options = { html: true })
+ return if !values[0] == !values[1]
+
+ step = Project::LifeCycleStep.find(key[/\d+/])
+
+ name = step.definition.name
+ label = options[:html] ? content_tag(:strong, name) : name
+
+ "#{label} #{activation_message(values:)}"
+ end
+
+ private
+
+ def activation_message(values:)
+ if values[1]
+ I18n.t("activity.project_life_cycle_step.activated")
+ elsif values[0]
+ I18n.t("activity.project_life_cycle_step.deactivated")
+ end
+ end
+end
diff --git a/lib/open_project/journal_formatter/project_life_cycle_step.rb b/lib/open_project/journal_formatter/project_life_cycle_step_dates.rb
similarity index 76%
rename from lib/open_project/journal_formatter/project_life_cycle_step.rb
rename to lib/open_project/journal_formatter/project_life_cycle_step_dates.rb
index ba7205f1577..d58678fe110 100644
--- a/lib/open_project/journal_formatter/project_life_cycle_step.rb
+++ b/lib/open_project/journal_formatter/project_life_cycle_step_dates.rb
@@ -28,44 +28,31 @@
# See COPYRIGHT and LICENSE files for more details.
#++
-class OpenProject::JournalFormatter::ProjectLifeCycleStep < JournalFormatter::Base
+class OpenProject::JournalFormatter::ProjectLifeCycleStepDates < JournalFormatter::Base
def render(key, values, options = { html: true })
step = Project::LifeCycleStep.find(key[/\d+/])
name = step.definition.name
label = options[:html] ? content_tag(:strong, name) : name
- messages = [
- activation_message(values:),
- date_change_message(values:, step:, options:)
- ]
+ message = date_change_message(values:, step:, options:)
- "#{label} #{messages.compact.to_sentence}"
+ "#{label} #{message}" if message
end
private
- def activation_message(values:)
- if values[:active]&.any?
- if values[:active][1]
- I18n.t("activity.project_life_cycle_step.activated")
- else
- I18n.t("activity.project_life_cycle_step.deactivated")
- end
- end
- end
-
def date_change_message(values:, step:, options:)
case step
when Project::Gate
- if values[:date]
- from, to = values[:date].map { format_date(_1) }
+ if values
+ from, to = values.map { format_date(_1&.begin) }
format_date_change(from:, to:, options:)
end
when Project::Stage
- if values[:date_range]
- from, to = values[:date_range].map { format_date_range(_1) }
+ if values
+ from, to = values.map { format_date_range(_1) }
format_date_change(from:, to:, options:)
end
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 054eb447091..9f281e5ce3e 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
@@ -59,19 +59,13 @@ module Acts::Journalized::Differ
#
# @param attributes [Array<Symbol>] the list of attributes for which to return changes.
# @param key_prefix [String] the prefix to add to each key in the resulting hash.
- # @param grouped [Boolean] whether to group changes by id or return them flat. Default is false.
# @return [Hash] when not grouped, a hash with key consisting of prefix, id and attribute name, and value being two
# element array with changes. When grouped, a hash with key consisting of prefix and id, and value being
# a hash with keys being attributes names and values being two element array with changes.
- def multiple_attributes_changes(attributes, key_prefix:, grouped: false)
+ def multiple_attributes_changes(attributes, key_prefix:)
attributes.each_with_object({}) do |attribute, result|
attribute_changes(attribute).each do |id, change|
- if grouped
- result["#{key_prefix}_#{id}"] ||= {}
- result["#{key_prefix}_#{id}"][attribute] = change
- else
- result["#{key_prefix}_#{id}_#{attribute}"] = change
- end
+ result["#{key_prefix}_#{id}_#{attribute}"] = change
end
end
end
diff --git a/lib_static/plugins/acts_as_journalized/lib/journal_changes.rb b/lib_static/plugins/acts_as_journalized/lib/journal_changes.rb
index 1d57319b540..39a3f55fe09 100644
--- a/lib_static/plugins/acts_as_journalized/lib/journal_changes.rb
+++ b/lib_static/plugins/acts_as_journalized/lib/journal_changes.rb
@@ -103,9 +103,8 @@ module JournalChanges
association: :project_life_cycle_step_journals,
id_attribute: :life_cycle_step_id
).multiple_attributes_changes(
- %i[active date date_range],
- key_prefix: "project_life_cycle_step",
- grouped: true
+ %i[active date_range],
+ key_prefix: "project_life_cycle_step"
)
end
diff --git a/spec/lib/acts/journalized/differ/association_spec.rb b/spec/lib/acts/journalized/differ/association_spec.rb
index 4228cc174a0..3499f5afcca 100644
--- a/spec/lib/acts/journalized/differ/association_spec.rb
+++ b/spec/lib/acts/journalized/differ/association_spec.rb
@@ -159,104 +159,50 @@ RSpec.describe Acts::Journalized::Differ::Association do
multiple_values:)
end
- describe "by default" do
- subject(:result) do
- instance.multiple_attributes_changes(
- %i[active start_date end_date],
- key_prefix: "project_life_cycle_steps"
- )
- end
-
- describe "requesting joined changes for all values" do
- let(:multiple_values) { :joined }
-
- it "returns the flat changes" do
- expect(result)
- .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_start_date" => ["", "2024-01-17"],
- "project_life_cycle_steps_3_end_date" => ["", "2024-01-18"],
-
- "project_life_cycle_steps_4_start_date" => ["2024-01-16", "2024-01-17"],
- "project_life_cycle_steps_4_end_date" => ["2024-01-17", "2024-01-18"]
- )
- end
- end
+ subject(:result) do
+ instance.multiple_attributes_changes(
+ %i[active start_date end_date],
+ key_prefix: "project_life_cycle_steps"
+ )
+ end
- describe "requesting single value change" do
- let(:multiple_values) { false }
+ describe "requesting joined changes for all values" do
+ let(:multiple_values) { :joined }
- it "returns the flat changes" do
- expect(result)
- .to eq(
- "project_life_cycle_steps_1_active" => [false, true],
+ it "returns the flat changes" do
+ expect(result)
+ .to eq(
+ "project_life_cycle_steps_1_active" => ["false", "true"],
- "project_life_cycle_steps_2_active" => [nil, true],
+ "project_life_cycle_steps_2_active" => [nil, "true"],
- "project_life_cycle_steps_3_active" => [true, false],
- "project_life_cycle_steps_3_start_date" => [nil, Date.new(2024, 1, 17)],
- "project_life_cycle_steps_3_end_date" => [nil, Date.new(2024, 1, 18)],
+ "project_life_cycle_steps_3_active" => ["true", "false"],
+ "project_life_cycle_steps_3_start_date" => ["", "2024-01-17"],
+ "project_life_cycle_steps_3_end_date" => ["", "2024-01-18"],
- "project_life_cycle_steps_4_start_date" => [Date.new(2024, 1, 16), Date.new(2024, 1, 17)],
- "project_life_cycle_steps_4_end_date" => [Date.new(2024, 1, 17), Date.new(2024, 1, 18)]
- )
- end
+ "project_life_cycle_steps_4_start_date" => ["2024-01-16", "2024-01-17"],
+ "project_life_cycle_steps_4_end_date" => ["2024-01-17", "2024-01-18"]
+ )
end
end
- describe "grouped" do
- subject(:result) do
- instance.multiple_attributes_changes(
- %i[active start_date end_date],
- key_prefix: "project_life_cycle_steps",
- grouped: true
- )
- end
+ describe "requesting single value change" do
+ let(:multiple_values) { false }
- describe "requesting joined changes for all values" do
- let(:multiple_values) { :joined }
+ it "returns the flat changes" do
+ expect(result)
+ .to eq(
+ "project_life_cycle_steps_1_active" => [false, true],
- it "returns the grouped changes" do
- expect(result)
- .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"],
- start_date: ["", "2024-01-17"],
- end_date: ["", "2024-01-18"]
- },
- "project_life_cycle_steps_4" => {
- start_date: ["2024-01-16", "2024-01-17"],
- end_date: ["2024-01-17", "2024-01-18"]
- }
- )
- end
- end
+ "project_life_cycle_steps_2_active" => [nil, true],
- describe "requesting single value change" do
- let(:multiple_values) { false }
+ "project_life_cycle_steps_3_active" => [true, false],
+ "project_life_cycle_steps_3_start_date" => [nil, Date.new(2024, 1, 17)],
+ "project_life_cycle_steps_3_end_date" => [nil, Date.new(2024, 1, 18)],
- it "returns the grouped changes" do
- expect(result)
- .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],
- start_date: [nil, Date.new(2024, 1, 17)],
- end_date: [nil, Date.new(2024, 1, 18)]
- },
- "project_life_cycle_steps_4" => {
- start_date: [Date.new(2024, 1, 16), Date.new(2024, 1, 17)],
- end_date: [Date.new(2024, 1, 17), Date.new(2024, 1, 18)]
- }
- )
- end
+ "project_life_cycle_steps_4_start_date" => [Date.new(2024, 1, 16), Date.new(2024, 1, 17)],
+ "project_life_cycle_steps_4_end_date" => [Date.new(2024, 1, 17), Date.new(2024, 1, 18)]
+ )
end
end
end
diff --git a/spec/lib/open_project/journal_formatter/project_life_cycle_step_active_spec.rb b/spec/lib/open_project/journal_formatter/project_life_cycle_step_active_spec.rb
new file mode 100644
index 00000000000..a308c7fd7de
--- /dev/null
+++ b/spec/lib/open_project/journal_formatter/project_life_cycle_step_active_spec.rb
@@ -0,0 +1,133 @@
+# frozen_string_literal: true
+
+#-- copyright
+# OpenProject is an open source project management software.
+# Copyright (C) the OpenProject GmbH
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License version 3.
+#
+# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
+# Copyright (C) 2006-2013 Jean-Philippe Lang
+# Copyright (C) 2010-2013 the ChiliProject Team
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+#
+# See COPYRIGHT and LICENSE files for more details.
+#++
+
+require "spec_helper"
+
+RSpec.describe OpenProject::JournalFormatter::ProjectLifeCycleStepActive do
+ describe "#render" do
+ let(:key) { "project_life_cycle_step_#{step.id}_active" }
+
+ subject(:result) { described_class.new(nil).render(key, values, html:) }
+
+ before do
+ allow(Project::LifeCycleStep).to receive(:find).with(step.id.to_s).and_return(step)
+ end
+
+ def date(day) = Date.new(2025, 1, day)
+
+ shared_examples "test result" do
+ context "with html output" do
+ let(:html) { true }
+
+ it { is_expected.to eq html_result }
+ end
+
+ context "with plain output" do
+ let(:html) { false }
+
+ it { is_expected.to eq plain_result }
+ end
+ end
+
+ describe "for gate changes" do
+ let(:step) { build_stubbed(:project_gate, definition:) }
+ let(:definition) { build_stubbed(:project_gate_definition, name: "The Gate") }
+
+ context "when activated" do
+ let(:values) { [false, true] }
+ let(:plain_result) { "The Gate activated" }
+ let(:html_result) { "<strong>The Gate</strong> activated" }
+
+ include_examples "test result"
+ end
+
+ context "when deactivated" do
+ let(:values) { [true, false] }
+ let(:plain_result) { "The Gate deactivated" }
+ let(:html_result) { "<strong>The Gate</strong> deactivated" }
+
+ include_examples "test result"
+ end
+
+ context "when no change between truthy values" do
+ let(:values) { [true, true] }
+ let(:plain_result) { nil }
+ let(:html_result) { nil }
+
+ include_examples "test result"
+ end
+
+ context "when no change between falsey values" do
+ let(:values) { [nil, false] }
+ let(:plain_result) { nil }
+ let(:html_result) { nil }
+
+ include_examples "test result"
+ end
+ end
+
+ describe "for stage changes" do
+ let(:step) { build_stubbed(:project_stage, definition:) }
+ let(:definition) { build_stubbed(:project_stage_definition, name: "The Stage") }
+
+ context "when activated" do
+ let(:values) { [false, true] }
+ let(:plain_result) { "The Stage activated" }
+ let(:html_result) { "<strong>The Stage</strong> activated" }
+
+ include_examples "test result"
+ end
+
+ context "when deactivated" do
+ let(:values) { [true, false] }
+ let(:plain_result) { "The Stage deactivated" }
+ let(:html_result) { "<strong>The Stage</strong> deactivated" }
+
+ include_examples "test result"
+ end
+
+ context "when no change between truthy values" do
+ let(:values) { [true, true] }
+ let(:plain_result) { nil }
+ let(:html_result) { nil }
+
+ include_examples "test result"
+ end
+
+ context "when no change between falsey values" do
+ let(:values) { [nil, false] }
+ let(:plain_result) { nil }
+ let(:html_result) { nil }
+
+ include_examples "test result"
+ end
+ end
+ end
+end
diff --git a/spec/lib/open_project/journal_formatter/project_life_cycle_step_spec.rb b/spec/lib/open_project/journal_formatter/project_life_cycle_step_dates_spec.rb
similarity index 65%
rename from spec/lib/open_project/journal_formatter/project_life_cycle_step_spec.rb
rename to spec/lib/open_project/journal_formatter/project_life_cycle_step_dates_spec.rb
index 05451fc94fd..44f1eccaa8f 100644
--- a/spec/lib/open_project/journal_formatter/project_life_cycle_step_spec.rb
+++ b/spec/lib/open_project/journal_formatter/project_life_cycle_step_dates_spec.rb
@@ -30,9 +30,9 @@
require "spec_helper"
-RSpec.describe OpenProject::JournalFormatter::ProjectLifeCycleStep do
+RSpec.describe OpenProject::JournalFormatter::ProjectLifeCycleStepDates do
describe "#render" do
- let(:key) { "project_life_cycle_step_#{step.id}" }
+ let(:key) { "project_life_cycle_step_#{step.id}_date_range" }
subject(:result) { described_class.new(nil).render(key, values, html:) }
@@ -60,24 +60,8 @@ RSpec.describe OpenProject::JournalFormatter::ProjectLifeCycleStep do
let(:step) { build_stubbed(:project_gate, definition:) }
let(:definition) { build_stubbed(:project_gate_definition, name: "The Gate") }
- context "when activated" do
- let(:values) { { active: [false, true] } }
- let(:plain_result) { "The Gate activated" }
- let(:html_result) { "<strong>The Gate</strong> activated" }
-
- include_examples "test result"
- end
-
- context "when deactivated" do
- let(:values) { { active: [true, false] } }
- let(:plain_result) { "The Gate deactivated" }
- let(:html_result) { "<strong>The Gate</strong> deactivated" }
-
- include_examples "test result"
- end
-
context "when date added" do
- let(:values) { { date: [nil, date(28)] } }
+ let(:values) { [nil, date(28)..] }
let(:plain_result) { "The Gate set to 01/28/2025" }
let(:html_result) { "<strong>The Gate</strong> set to 01/28/2025" }
@@ -85,7 +69,7 @@ RSpec.describe OpenProject::JournalFormatter::ProjectLifeCycleStep do
end
context "when date changed" do
- let(:values) { { date: [date(28), date(29)] } }
+ let(:values) { [date(28).., date(29)..] }
let(:plain_result) { "The Gate changed from 01/28/2025 to 01/29/2025" }
let(:html_result) { "<strong>The Gate</strong> changed from 01/28/2025 to 01/29/2025" }
@@ -93,17 +77,17 @@ RSpec.describe OpenProject::JournalFormatter::ProjectLifeCycleStep do
end
context "when date removed" do
- let(:values) { { date: [date(28), nil] } }
+ let(:values) { [date(28).., nil] }
let(:plain_result) { "The Gate date deleted 01/28/2025" }
let(:html_result) { "<strong>The Gate</strong> date deleted <del>01/28/2025</del>" }
include_examples "test result"
end
- context "when activated and date added" do
- let(:values) { { active: [false, true], date: [nil, date(28)] } }
- let(:plain_result) { "The Gate activated and set to 01/28/2025" }
- let(:html_result) { "<strong>The Gate</strong> activated and set to 01/28/2025" }
+ context "when both dates absent" do
+ let(:values) { [nil, nil] }
+ let(:plain_result) { nil }
+ let(:html_result) { nil }
include_examples "test result"
end
@@ -113,24 +97,8 @@ RSpec.describe OpenProject::JournalFormatter::ProjectLifeCycleStep do
let(:step) { build_stubbed(:project_stage, definition:) }
let(:definition) { build_stubbed(:project_stage_definition, name: "The Stage") }
- context "when activated" do
- let(:values) { { active: [false, true] } }
- let(:plain_result) { "The Stage activated" }
- let(:html_result) { "<strong>The Stage</strong> activated" }
-
- include_examples "test result"
- end
-
- context "when deactivated" do
- let(:values) { { active: [true, false] } }
- let(:plain_result) { "The Stage deactivated" }
- let(:html_result) { "<strong>The Stage</strong> deactivated" }
-
- include_examples "test result"
- end
-
context "when date range added" do
- let(:values) { { date_range: [nil, date(28)..date(29)] } }
+ let(:values) { [nil, date(28)..date(29)] }
let(:plain_result) { "The Stage set to 01/28/2025 - 01/29/2025" }
let(:html_result) { "<strong>The Stage</strong> set to 01/28/2025 - 01/29/2025" }
@@ -138,7 +106,7 @@ RSpec.describe OpenProject::JournalFormatter::ProjectLifeCycleStep do
end
context "when date range changed" do
- let(:values) { { date_range: [date(28)..date(29), date(28)..date(30)] } }
+ let(:values) { [date(28)..date(29), date(28)..date(30)] }
let(:plain_result) { "The Stage changed from 01/28/2025 - 01/29/2025 to 01/28/2025 - 01/30/2025" }
let(:html_result) { "<strong>The Stage</strong> changed from 01/28/2025 - 01/29/2025 to 01/28/2025 - 01/30/2025" }
@@ -146,17 +114,17 @@ RSpec.describe OpenProject::JournalFormatter::ProjectLifeCycleStep do
end
context "when date range removed" do
- let(:values) { { date_range: [date(28)..date(29), nil] } }
+ let(:values) { [date(28)..date(29), nil] }
let(:plain_result) { "The Stage date deleted 01/28/2025 - 01/29/2025" }
let(:html_result) { "<strong>The Stage</strong> date deleted <del>01/28/2025 - 01/29/2025</del>" }
include_examples "test result"
end
- context "when activated and date range added" do
- let(:values) { { active: [false, true], date_range: [nil, date(28)..date(29)] } }
- let(:plain_result) { "The Stage activated and set to 01/28/2025 - 01/29/2025" }
- let(:html_result) { "<strong>The Stage</strong> activated and set to 01/28/2025 - 01/29/2025" }
+ context "when both date ranges absent" do
+ let(:values) { [nil, nil] }
+ let(:plain_result) { nil }
+ let(:html_result) { nil }
include_examples "test result"
end
diff --git a/spec/models/projects/project_acts_as_journalized_spec.rb b/spec/models/projects/project_acts_as_journalized_spec.rb
index 7cb1c26f6e0..aac0a4455f2 100644
--- a/spec/models/projects/project_acts_as_journalized_spec.rb
+++ b/spec/models/projects/project_acts_as_journalized_spec.rb
@@ -213,8 +213,8 @@ RSpec.describe Project, "acts_as_journalized" do
expect(project.last_journal.details).to eq(
{
- "project_life_cycle_step_#{stage.id}" => { "active" => [nil, true] },
- "project_life_cycle_step_#{gate.id}" => { "active" => [nil, true] }
+ "project_life_cycle_step_#{stage.id}_active" => [nil, true],
+ "project_life_cycle_step_#{gate.id}_active" => [nil, true]
}
)
end
@@ -232,8 +232,8 @@ RSpec.describe Project, "acts_as_journalized" do
expect(project.last_journal.details).to eq(
{
- "project_life_cycle_step_#{stage.id}" => { "active" => [true, false] },
- "project_life_cycle_step_#{gate.id}" => { "active" => [true, false] }
+ "project_life_cycle_step_#{stage.id}_active" => [true, false],
+ "project_life_cycle_step_#{gate.id}_active" => [true, false]
}
)
end
@@ -260,17 +260,14 @@ RSpec.describe Project, "acts_as_journalized" do
expect(project.last_journal.details).to match(
{
- "project_life_cycle_step_#{stage.id}" => hash_including(
- "date_range" => [
- nil,
- Date.new(2025, 1, 30)..Date.new(2025, 1, 31)
- ]
- ),
- "project_life_cycle_step_#{gate.id}" => hash_including(
- "date" => [
- nil, Date.new(2025, 2, 1)
- ]
- )
+ "project_life_cycle_step_#{stage.id}_date_range" => [
+ nil,
+ Date.new(2025, 1, 30)..Date.new(2025, 1, 31)
+ ],
+ "project_life_cycle_step_#{gate.id}_date_range" => [
+ nil,
+ Date.new(2025, 2, 1)..
+ ]
}
)
end
@@ -288,18 +285,14 @@ RSpec.describe Project, "acts_as_journalized" do
expect(project.last_journal.details).to match(
{
- "project_life_cycle_step_#{stage.id}" => hash_including(
- "date_range" => [
- Date.new(2025, 1, 30)..Date.new(2025, 1, 31),
- Date.new(2025, 1, 30)..Date.new(2025, 2, 1)
- ]
- ),
- "project_life_cycle_step_#{gate.id}" => hash_including(
- "date" => [
- Date.new(2025, 2, 1),
- Date.new(2025, 2, 3)
- ]
- )
+ "project_life_cycle_step_#{stage.id}_date_range" => [
+ Date.new(2025, 1, 30)..Date.new(2025, 1, 31),
+ Date.new(2025, 1, 30)..Date.new(2025, 2, 1)
+ ],
+ "project_life_cycle_step_#{gate.id}_date_range" => [
+ Date.new(2025, 2, 1)..,
+ Date.new(2025, 2, 3)..
+ ]
}
)
end
@@ -317,18 +310,14 @@ RSpec.describe Project, "acts_as_journalized" do
expect(project.last_journal.details).to match(
{
- "project_life_cycle_step_#{stage.id}" => hash_including(
- "date_range" => [
- Date.new(2025, 1, 30)..Date.new(2025, 1, 31),
- nil
- ]
- ),
- "project_life_cycle_step_#{gate.id}" => hash_including(
- "date" => [
- Date.new(2025, 2, 1),
- nil
- ]
- )
+ "project_life_cycle_step_#{stage.id}_date_range" => [
+ Date.new(2025, 1, 30)..Date.new(2025, 1, 31),
+ nil
+ ],
+ "project_life_cycle_step_#{gate.id}_date_range" => [
+ Date.new(2025, 2, 1)..,
+ nil
+ ]
}
)
end
@@ -346,20 +335,16 @@ RSpec.describe Project, "acts_as_journalized" do
expect(project.last_journal.details).to match(
{
- "project_life_cycle_step_#{stage.id}" => hash_including(
- "active" => [nil, true],
- "date_range" => [
- nil,
- Date.new(2025, 1, 30)..Date.new(2025, 1, 31)
- ]
- ),
- "project_life_cycle_step_#{gate.id}" => hash_including(
- "active" => [nil, true],
- "date" => [
- nil,
- Date.new(2025, 2, 1)
- ]
- )
+ "project_life_cycle_step_#{stage.id}_active" => [nil, true],
+ "project_life_cycle_step_#{stage.id}_date_range" => [
+ nil,
+ Date.new(2025, 1, 30)..Date.new(2025, 1, 31)
+ ],
+ "project_life_cycle_step_#{gate.id}_active" => [nil, true],
+ "project_life_cycle_step_#{gate.id}_date_range" => [
+ nil,
+ Date.new(2025, 2, 1)..
+ ]
}
)
end