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

clearer differ association method names

Ivan Kuchin4e16122a459c
diff --git a/app/models/journable/with_historic_attributes.rb b/app/models/journable/with_historic_attributes.rb
index 6ff5d61b6aa..eb59ebe8fff 100644
--- a/app/models/journable/with_historic_attributes.rb
+++ b/app/models/journable/with_historic_attributes.rb
@@ -254,7 +254,7 @@ class Journable::WithHistoricAttributes < SimpleDelegator
association: :custom_values,
id_attribute: :custom_field_id,
all_values: :joined
- ).attribute_changes(
+ ).single_attribute_changes(
:value,
key_prefix: "custom_field"
)
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 05356acdb2c..bd1f08af905 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
@@ -37,14 +37,14 @@ module Acts::Journalized::Differ
@all_values = all_values
end
- def attribute_changes(attribute, key_prefix:)
- single_attribute_changes(attribute)
+ def single_attribute_changes(attribute, key_prefix:)
+ attribute_changes(attribute)
.transform_keys { |id| "#{key_prefix}_#{id}" }
end
- def attributes_changes(attributes, key_prefix:, grouped: false)
+ def multiple_attributes_changes(attributes, key_prefix:, grouped: false)
attributes.each_with_object({}) do |attribute, result|
- single_attribute_changes(attribute).each do |id, change|
+ attribute_changes(attribute).each do |id, change|
if grouped
result["#{key_prefix}_#{id}"] ||= {}
result["#{key_prefix}_#{id}"][attribute] = change
@@ -69,7 +69,7 @@ module Acts::Journalized::Differ
relation.group_by(&id_attribute.to_sym)
end
- def single_attribute_changes(attribute)
+ def attribute_changes(attribute)
attribute = attribute.to_sym
pairs = @ids.index_with do |id|
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 b2c52921f95..8ed905c7d66 100644
--- a/lib_static/plugins/acts_as_journalized/lib/journal_changes.rb
+++ b/lib_static/plugins/acts_as_journalized/lib/journal_changes.rb
@@ -63,7 +63,7 @@ module JournalChanges
association: :attachable_journals,
id_attribute: :attachment_id,
all_values: :joined
- ).attribute_changes(
+ ).single_attribute_changes(
:filename,
key_prefix: "attachments"
)
@@ -88,7 +88,7 @@ module JournalChanges
association:,
id_attribute: :custom_field_id,
all_values: :joined
- ).attribute_changes(
+ ).single_attribute_changes(
:value,
key_prefix: "custom_fields"
)
@@ -102,7 +102,7 @@ module JournalChanges
self,
association: :project_life_cycle_step_journals,
id_attribute: :life_cycle_step_id
- ).attributes_changes(
+ ).multiple_attributes_changes(
%i[active date date_range],
key_prefix: "project_life_cycle_step",
grouped: true
@@ -127,7 +127,7 @@ module JournalChanges
association: :agenda_item_journals,
id_attribute: :agenda_item_id,
all_values: :joined
- ).attributes_changes(
+ ).multiple_attributes_changes(
%i[title duration_in_minutes notes position work_package_id],
key_prefix: "agenda_items"
)
diff --git a/spec/lib/acts/journalized/differ/association_spec.rb b/spec/lib/acts/journalized/differ/association_spec.rb
index f94f7f59633..2167d2c1966 100644
--- a/spec/lib/acts/journalized/differ/association_spec.rb
+++ b/spec/lib/acts/journalized/differ/association_spec.rb
@@ -31,7 +31,7 @@
require "spec_helper"
RSpec.describe Acts::Journalized::Differ::Association do
- describe "#attribute_changes" do
+ describe "#single_attribute_changes" do
let(:original) do
build(:work_package,
custom_values: [
@@ -75,7 +75,7 @@ RSpec.describe Acts::Journalized::Differ::Association do
end
subject(:result) do
- instance.attribute_changes(:value, key_prefix: "custom_field")
+ instance.single_attribute_changes(:value, key_prefix: "custom_field")
end
describe "requesting all values changes joined" do
@@ -128,7 +128,7 @@ RSpec.describe Acts::Journalized::Differ::Association do
end
end
- describe "#attributes_changes" do
+ describe "#multiple_attributes_changes" do
let(:original) do
build(:journal, project_life_cycle_step_journals: [
build_stubbed(:project_life_cycle_step_journal, life_cycle_step_id: 1, active: false),
@@ -161,7 +161,7 @@ RSpec.describe Acts::Journalized::Differ::Association do
describe "by default" do
subject(:result) do
- instance.attributes_changes(
+ instance.multiple_attributes_changes(
%i[active start_date end_date],
key_prefix: "project_life_cycle_steps"
)
@@ -204,7 +204,7 @@ RSpec.describe Acts::Journalized::Differ::Association do
describe "grouped" do
subject(:result) do
- instance.attributes_changes(
+ instance.multiple_attributes_changes(
%i[active start_date end_date],
key_prefix: "project_life_cycle_steps",
grouped: true