From 357fd3215f049ebd493c5ddebc393ca07fb324a6 Mon Sep 17 00:00:00 2001 From: pezholio Date: Mon, 27 Jan 2025 14:18:08 +0000 Subject: [PATCH] Append edition_actions into history This updates the `edition_actions` helper to accept an array of host_content_update events, filter by if they apply to the edition, then cast as an actionable item. --- app/helpers/action_helper.rb | 7 +- app/views/shared/_edition_history.html.erb | 2 +- app/views/shared/_history.html.erb | 2 +- .../host_content_update_history_test.rb | 143 ++++++++++++++++++ test/unit/helpers/admin/action_helper_test.rb | 40 +++++ 5 files changed, 190 insertions(+), 4 deletions(-) create mode 100644 test/integration/host_content_update_history_test.rb diff --git a/app/helpers/action_helper.rb b/app/helpers/action_helper.rb index 11e1d6d61..5f1dd9d9a 100644 --- a/app/helpers/action_helper.rb +++ b/app/helpers/action_helper.rb @@ -1,8 +1,11 @@ module ActionHelper - def edition_actions(edition) - edition.actions.reverse.delete_if do |a| + def edition_actions(edition, update_events) + actions = edition.actions.reject do |a| [Action::IMPORTANT_NOTE, Action::IMPORTANT_NOTE_RESOLVED].include?(a.request_type) end + update_actions = update_events.select { |e| e.is_for_edition?(edition) }.map(&:to_action) + actions.append(*update_actions) + actions.sort_by(&:created_at).reverse end def action_note?(action) diff --git a/app/views/shared/_edition_history.html.erb b/app/views/shared/_edition_history.html.erb index 47ff1f5d5..ba5bed30a 100644 --- a/app/views/shared/_edition_history.html.erb +++ b/app/views/shared/_edition_history.html.erb @@ -12,7 +12,7 @@