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

keep order of original and changed same

Ivan Kuchind277fe9bf36c
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 d1a364cbc96..069ec0d23f6 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
@@ -80,14 +80,14 @@ module Acts::Journalized
end
def get_association_changes(original, changed, association, association_name, key, value)
- new_journals = changed.send(association).map(&:attributes)
old_journals = original&.send(association)&.map(&:attributes) || []
+ new_journals = changed.send(association).map(&:attributes)
- changes_on_association(new_journals, old_journals, association_name, key, value)
+ changes_on_association(old_journals, new_journals, association_name, key, value)
end
- def changes_on_association(current, original, association_name, key, value)
- merged_journals = merge_reference_journals_by_id(current, original, key.to_s, value.to_s)
+ def changes_on_association(original, current, association_name, key, value)
+ merged_journals = merge_reference_journals_by_id(original, current, key.to_s, value.to_s)
changes = added_references(merged_journals)
.merge(removed_references(merged_journals))
@@ -117,7 +117,7 @@ module Acts::Journalized
end
end
- def merge_reference_journals_by_id(new_journals, old_journals, id_key, value)
+ def merge_reference_journals_by_id(old_journals, new_journals, id_key, value)
all_associated_journal_ids = (new_journals.pluck(id_key) | old_journals.pluck(id_key)).compact
all_associated_journal_ids.index_with do |id|