From f1e67478224ff51b6e08803e31ca585526b5942b Mon Sep 17 00:00:00 2001
From: Takashi Kato <tohosaku@users.osdn.me>
Date: Wed, 23 Oct 2024 13:25:26 +0000
Subject: [PATCH 2/2] Upgrade propshaft to 1.1.0

---
 Gemfile                                  |  2 +-
 config/initializers/10-patches.rb        |  2 +-
 lib/redmine/asset_path.rb                | 18 +++++++++---------
 test/unit/lib/redmine/asset_path_test.rb |  2 +-
 4 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/Gemfile b/Gemfile
index 60633a5529..ce9a915bb3 100644
--- a/Gemfile
+++ b/Gemfile
@@ -14,7 +14,7 @@ gem 'i18n', '~> 1.14.1'
 gem 'rbpdf', '~> 1.21.3'
 gem 'addressable'
 gem 'rubyzip', '~> 2.3.0'
-gem 'propshaft', '~> 0.8.0'
+gem 'propshaft', '~> 1.1.0'
 gem 'rack', '>= 3.1.3'
 
 #  Ruby Standard Gems
diff --git a/config/initializers/10-patches.rb b/config/initializers/10-patches.rb
index 52e6d2a21a..0cee95cce5 100644
--- a/config/initializers/10-patches.rb
+++ b/config/initializers/10-patches.rb
@@ -132,7 +132,7 @@ module Propshaft
     end
 
     def load_path
-      @load_path ||= Redmine::AssetLoadPath.new(config)
+      @load_path ||= Redmine::AssetLoadPath.new(config, compilers)
     end
   end)
 
diff --git a/lib/redmine/asset_path.rb b/lib/redmine/asset_path.rb
index d425d39f04..4c7959a587 100644
--- a/lib/redmine/asset_path.rb
+++ b/lib/redmine/asset_path.rb
@@ -29,14 +29,14 @@ module Redmine
       @version = Rails.application.config.assets.version
     end
 
-    def update(transition_map:, assets:)
+    def update(transition_map:, assets:, load_path:)
       each_file do |file, intermediate_path, logical_path|
         @transition.add_src  intermediate_path, logical_path
         @transition.add_dest intermediate_path, logical_path
         asset = if file.extname == '.css'
-                  Redmine::Asset.new(file,   logical_path: logical_path, version: version, transition_map: transition_map)
+                  Redmine::Asset.new(file,   logical_path: logical_path, load_path: load_path, transition_map: transition_map)
                 else
-                  Propshaft::Asset.new(file, logical_path: logical_path, version: version)
+                  Propshaft::Asset.new(file, logical_path: logical_path, load_path: load_path)
                 end
         assets[asset.logical_path.to_s] ||= asset
       end
@@ -132,10 +132,10 @@ module Redmine
   class AssetLoadPath < Propshaft::LoadPath
     attr_reader :extension_paths, :default_asset_path, :transition_map
 
-    def initialize(config)
+    def initialize(config, compilers)
       @extension_paths    = config.redmine_extension_paths
       @default_asset_path = config.redmine_default_asset_path
-      super(config.paths, version: config.version)
+      super(config.paths, compilers: compilers, version: config.version)
     end
 
     def asset_files
@@ -156,13 +156,13 @@ module Redmine
       super
       if merge_required
         @transition_map = {}
-        default_asset_path.update(assets: @cached_assets_by_path, transition_map: transition_map)
+        default_asset_path.update(assets: @cached_assets_by_path, transition_map: transition_map, load_path: self)
         extension_paths.each do |asset_path|
           # Support link from extension assets to assets in the application
           default_asset_path.each_file do |file, intermediate_path, logical_path|
             asset_path.instance_eval { @transition.add_dest intermediate_path, logical_path }
           end
-          asset_path.update(assets: @cached_assets_by_path, transition_map: transition_map)
+          asset_path.update(assets: @cached_assets_by_path, transition_map: transition_map, load_path: self)
         end
       end
       @cached_assets_by_path
@@ -189,9 +189,9 @@ module Redmine
   end
 
   class Asset < Propshaft::Asset
-    def initialize(file, logical_path:, version:, transition_map:)
+    def initialize(file, logical_path:, load_path:, transition_map:)
       @transition_map = transition_map
-      super(file, logical_path: logical_path, version: version)
+      super(file, logical_path: logical_path, load_path: load_path)
     end
 
     def content
diff --git a/test/unit/lib/redmine/asset_path_test.rb b/test/unit/lib/redmine/asset_path_test.rb
index a4f12f0e35..bad93f8b03 100644
--- a/test/unit/lib/redmine/asset_path_test.rb
+++ b/test/unit/lib/redmine/asset_path_test.rb
@@ -26,7 +26,7 @@ class Redmine::AssetPathTest < ActiveSupport::TestCase
     @asset_path = Redmine::AssetPath.new(assets_dir, paths, 'plugin_assets/foo/')
     @assets = {}
     @transition_map = {}
-    @asset_path.update(transition_map: @transition_map, assets: @assets)
+    @asset_path.update(transition_map: @transition_map, assets: @assets, load_path: nil)
   end
 
   test "asset path size" do
-- 
2.39.2

