From cc4659a308590be083065f19df8571efc345052a Mon Sep 17 00:00:00 2001 From: erdgeist Date: Tue, 21 Jul 2026 15:39:56 +0200 Subject: Remove Page#update_assets Only caller left was the sort_images action removed last commit. Kept alive only as a test-setup convenience for diff_against coverage, which is what it actually was -- an implicit API with no deliberate contract, sitting there for anyone to call. Rewrote the one test to set up its fixture state directly via related_assets rather than through a method whose real job was already done. --- app/models/page.rb | 16 ---------------- test/models/page_test.rb | 8 ++++++-- 2 files changed, 6 insertions(+), 18 deletions(-) diff --git a/app/models/page.rb b/app/models/page.rb index ab42b1c..c1498fc 100644 --- a/app/models/page.rb +++ b/app/models/page.rb @@ -319,22 +319,6 @@ class Page < ApplicationRecord end end - def update_assets image_ids - transaction do - previous_headline_asset_id = self.related_assets.find_by(headline: true)&.asset_id - - self.related_assets.delete_all - - if image_ids - image_ids.each_with_index do |id, index| - asset = Asset.find(id) - self.related_assets.create!(:asset_id => asset.id, :position => index+1, - :headline => asset.id == previous_headline_asset_id) - end - end - end - end - # Installs (or re-installs) the trigger that keeps page_translations' # search_vector in sync. Idempotent, safe to call on every boot. # search_vector is populated by a raw Postgres trigger, not anything diff --git a/test/models/page_test.rb b/test/models/page_test.rb index 1f924f9..98a00d2 100644 --- a/test/models/page_test.rb +++ b/test/models/page_test.rb @@ -309,11 +309,15 @@ class PageTest < ActiveSupport::TestCase kept_asset = Asset.create!(:upload_file_name => "kept.png", :upload_content_type => "image/png", :upload_file_size => 1) removed_asset = Asset.create!(:upload_file_name => "removed.pdf", :upload_content_type => "application/pdf", :upload_file_size => 1) - n.head.update_assets([kept_asset.id, removed_asset.id]) + n.head.related_assets.delete_all + n.head.related_assets.create!(:asset_id => kept_asset.id, :position => 1) + n.head.related_assets.create!(:asset_id => removed_asset.id, :position => 2) d2 = find_or_create_draft(n, @user1) added_asset = Asset.create!(:upload_file_name => "added.png", :upload_content_type => "image/png", :upload_file_size => 1) - d2.update_assets([kept_asset.id, added_asset.id]) + d2.related_assets.delete_all + d2.related_assets.create!(:asset_id => kept_asset.id, :position => 1) + d2.related_assets.create!(:asset_id => added_asset.id, :position => 2) d2.save! diff = d2.diff_against(n.head) -- cgit v1.3