From 112e3ddeb856e46f36c1ca80b136db32e464b48b Mon Sep 17 00:00:00 2001
From: Takashi Kato <tohosaku@users.osdn.me>
Date: Thu, 8 Dec 2022 21:33:34 +0000
Subject: [PATCH 3/3] Fix tests

---
 test/helpers/application_helper_test.rb     | 16 ++++++++--------
 test/helpers/avatars_helper_test.rb         |  4 ++--
 test/integration/layout_test.rb             | 18 +++++++++---------
 test/integration/lib/redmine/hook_test.rb   |  2 +-
 test/integration/lib/redmine/themes_test.rb | 16 ++++++++--------
 test/test_helper.rb                         |  1 +
 6 files changed, 29 insertions(+), 28 deletions(-)

diff --git a/test/helpers/application_helper_test.rb b/test/helpers/application_helper_test.rb
index a9e3b3a74..bf596ee3f 100644
--- a/test/helpers/application_helper_test.rb
+++ b/test/helpers/application_helper_test.rb
@@ -2037,16 +2037,16 @@ class ApplicationHelperTest < Redmine::HelperTest
   end
 
   def test_stylesheet_link_tag_should_pick_the_default_stylesheet
-    assert_match 'href="/stylesheets/styles.css"', stylesheet_link_tag("styles")
+    assert_match 'href="/assets/styles.css"', stylesheet_link_tag("styles")
   end
 
   def test_stylesheet_link_tag_for_plugin_should_pick_the_plugin_stylesheet
-    assert_match 'href="/plugin_assets/foo/stylesheets/styles.css"',
+    assert_match 'href="/assets/plugin_assets/foo/styles.css"',
                  stylesheet_link_tag("styles", :plugin => :foo)
   end
 
   def test_image_tag_should_pick_the_default_image
-    assert_match 'src="/images/image.png"', image_tag("image.png")
+    assert_match 'src="/assets/image.png"', image_tag("image.png")
   end
 
   def test_image_tag_should_pick_the_theme_image_if_it_exists
@@ -2054,23 +2054,23 @@ class ApplicationHelperTest < Redmine::HelperTest
     theme.images << 'image.png'
 
     with_settings :ui_theme => theme.id do
-      assert_match %|src="/themes/#{theme.dir}/images/image.png"|, image_tag("image.png")
-      assert_match %|src="/images/other.png"|, image_tag("other.png")
+      assert_match %|src="/assets/themes/#{theme.dir}/image.png"|, image_tag("image.png")
+      assert_match %|src="/assets/other.png"|, image_tag("other.png")
     end
   ensure
     theme.images.delete 'image.png'
   end
 
   def test_image_tag_sfor_plugin_should_pick_the_plugin_image
-    assert_match 'src="/plugin_assets/foo/images/image.png"', image_tag("image.png", :plugin => :foo)
+    assert_match 'src="/assets/plugin_assets/foo/image.png"', image_tag("image.png", :plugin => :foo)
   end
 
   def test_javascript_include_tag_should_pick_the_default_javascript
-    assert_match 'src="/javascripts/scripts.js"', javascript_include_tag("scripts")
+    assert_match 'src="/assets/scripts.js"', javascript_include_tag("scripts")
   end
 
   def test_javascript_include_tag_for_plugin_should_pick_the_plugin_javascript
-    assert_match 'src="/plugin_assets/foo/javascripts/scripts.js"', javascript_include_tag("scripts", :plugin => :foo)
+    assert_match 'src="/assets/plugin_assets/foo/scripts.js"', javascript_include_tag("scripts", :plugin => :foo)
   end
 
   def test_raw_json_should_escape_closing_tags
diff --git a/test/helpers/avatars_helper_test.rb b/test/helpers/avatars_helper_test.rb
index ab28a6d65..cc74a47df 100644
--- a/test/helpers/avatars_helper_test.rb
+++ b/test/helpers/avatars_helper_test.rb
@@ -39,11 +39,11 @@ class AvatarsHelperTest < Redmine::HelperTest
   end
 
   def test_avatar_with_anonymous_user
-    assert_match %r{src="/images/anonymous.png(\?\d+)?"}, avatar(User.anonymous)
+    assert_match %r{src="/assets/anonymous(-\w+)?.png"}, avatar(User.anonymous)
   end
 
   def test_avatar_with_group
-    assert_match %r{src="/images/group.png(\?\d+)?"}, avatar(Group.first)
+    assert_match %r{src="/assets/group(-\w+)?.png"}, avatar(Group.first)
   end
 
   def test_avatar_with_invalid_arg_should_return_nil
diff --git a/test/integration/layout_test.rb b/test/integration/layout_test.rb
index 662ca55ca..b6112ff87 100644
--- a/test/integration/layout_test.rb
+++ b/test/integration/layout_test.rb
@@ -65,29 +65,29 @@ class LayoutTest < Redmine::IntegrationTest
     Role.anonymous.add_permission! :add_issues
 
     get '/projects/ecookbook/issues/new'
-    assert_select 'head script[src^=?]', '/javascripts/jstoolbar/jstoolbar.js?'
+    assert_select "head script:match('src',?)", %r{/assets/jstoolbar/jstoolbar-\w+.js}
     assert_include "var userHlLanguages = #{UserPreference::DEFAULT_TOOLBAR_LANGUAGE_OPTIONS.to_json};", response.body
   end
 
   def test_calendar_header_tags
     with_settings :default_language => 'fr' do
       get '/issues'
-      assert_include "/javascripts/i18n/datepicker-fr.js", response.body
+      assert_match %r{/assets/i18n/datepicker-fr-\w+.js}, response.body
     end
 
     with_settings :default_language => 'en-GB' do
       get '/issues'
-      assert_include "/javascripts/i18n/datepicker-en-GB.js", response.body
+      assert_match %r{/assets/i18n/datepicker-en-GB-\w+.js}, response.body
     end
 
     with_settings :default_language => 'en' do
       get '/issues'
-      assert_not_include "/javascripts/i18n/datepicker", response.body
+      assert_not_include "/assets/i18n/datepicker", response.body
     end
 
     with_settings :default_language => 'es' do
       get '/issues'
-      assert_include "/javascripts/i18n/datepicker-es.js", response.body
+      assert_match %r{/assets/i18n/datepicker-es-\w+.js}, response.body
     end
 
     with_settings :default_language => 'es-PA' do
@@ -99,22 +99,22 @@ class LayoutTest < Redmine::IntegrationTest
 
     with_settings :default_language => 'zh' do
       get '/issues'
-      assert_include "/javascripts/i18n/datepicker-zh-CN.js", response.body
+      assert_match %r{/assets/i18n/datepicker-zh-CN-\w+.js}, response.body
     end
 
     with_settings :default_language => 'zh-TW' do
       get '/issues'
-      assert_include "/javascripts/i18n/datepicker-zh-TW.js", response.body
+      assert_match %r{/assets/i18n/datepicker-zh-TW-\w+.js}, response.body
     end
 
     with_settings :default_language => 'pt' do
       get '/issues'
-      assert_include "/javascripts/i18n/datepicker-pt.js", response.body
+      assert_match %r{/assets/i18n/datepicker-pt-\w+.js}, response.body
     end
 
     with_settings :default_language => 'pt-BR' do
       get '/issues'
-      assert_include "/javascripts/i18n/datepicker-pt-BR.js", response.body
+      assert_match %r{/assets/i18n/datepicker-pt-BR-\w+.js}, response.body
     end
   end
 
diff --git a/test/integration/lib/redmine/hook_test.rb b/test/integration/lib/redmine/hook_test.rb
index e7f2fa35a..13d154677 100644
--- a/test/integration/lib/redmine/hook_test.rb
+++ b/test/integration/lib/redmine/hook_test.rb
@@ -78,7 +78,7 @@ class HookTest < Redmine::IntegrationTest
     Redmine::Hook.add_listener(ProjectBasedTemplate)
 
     get '/projects/ecookbook'
-    assert_select 'head link[href=?]', '/stylesheets/ecookbook.css'
+    assert_select 'head link[href=?]', '/assets/ecookbook.css'
   end
 
   def test_empty_sidebar_should_be_hidden
diff --git a/test/integration/lib/redmine/themes_test.rb b/test/integration/lib/redmine/themes_test.rb
index f7434468f..d058df830 100644
--- a/test/integration/lib/redmine/themes_test.rb
+++ b/test/integration/lib/redmine/themes_test.rb
@@ -35,7 +35,7 @@ class ThemesTest < Redmine::IntegrationTest
     get '/'
 
     assert_response :success
-    assert_select "link[rel=stylesheet][href^=?]", "/themes/#{@theme.dir}/stylesheets/application.css"
+    assert_select "link[rel=stylesheet]:match('href', ?)", %r{/assets/themes/#{@theme.dir}/application-\w+\.css}
   end
 
   def test_without_theme_js
@@ -44,7 +44,7 @@ class ThemesTest < Redmine::IntegrationTest
     get '/'
 
     assert_response :success
-    assert_select "script[src^=?]", "/themes/#{@theme.dir}/javascripts/theme.js", 0
+    assert_select "script[src^=?]", "/assets/themes/#{@theme.dir}/theme.js", 0
   end
 
   def test_with_theme_js
@@ -53,7 +53,7 @@ class ThemesTest < Redmine::IntegrationTest
     get '/'
 
     assert_response :success
-    assert_select "script[src^=?]", "/themes/#{@theme.dir}/javascripts/theme.js", 1
+    assert_select "script[src^=?]", "/assets/themes/#{@theme.dir}/theme.js", 1
   ensure
     @theme.javascripts.delete 'theme'
   end
@@ -72,7 +72,7 @@ class ThemesTest < Redmine::IntegrationTest
     get '/'
 
     assert_response :success
-    assert_select 'link[rel="shortcut icon"][href^=?]', "/themes/#{@theme.dir}/favicon/a.ico"
+    assert_select 'link[rel="shortcut icon"][href^=?]', "/assets/themes/#{@theme.dir}/a.ico"
   ensure
     @theme.favicons.delete 'a.ico'
   end
@@ -83,7 +83,7 @@ class ThemesTest < Redmine::IntegrationTest
 
     assert_response :success
     assert_select 'link[rel="shortcut icon"]', 1
-    assert_select 'link[rel="shortcut icon"][href^=?]', "/themes/#{@theme.dir}/favicon/b.ico"
+    assert_select 'link[rel="shortcut icon"][href^=?]', "/assets/themes/#{@theme.dir}/b.ico"
   ensure
     @theme.favicons.delete("b.ico")
     @theme.favicons.delete("a.png")
@@ -96,9 +96,9 @@ class ThemesTest < Redmine::IntegrationTest
     get '/'
 
     assert_response :success
-    assert_select "link[rel=stylesheet][href^=?]", "/foo/themes/#{@theme.dir}/stylesheets/application.css"
-    assert_select "script[src^=?]", "/foo/themes/#{@theme.dir}/javascripts/theme.js"
-    assert_select 'link[rel="shortcut icon"][href^=?]', "/foo/themes/#{@theme.dir}/favicon/a.ico"
+    assert_select "link[rel=stylesheet]:match('href', ?)", %r{/foo/assets/themes/#{@theme.dir}/application-\w+\.css}
+    assert_select "script[src^=?]", "/foo/assets/themes/#{@theme.dir}/theme.js"
+    assert_select 'link[rel="shortcut icon"][href^=?]', "/foo/assets/themes/#{@theme.dir}/a.ico"
   ensure
     Redmine::Utils.relative_url_root = ''
   end
diff --git a/test/test_helper.rb b/test/test_helper.rb
index c5fe079c8..786dc9e35 100644
--- a/test/test_helper.rb
+++ b/test/test_helper.rb
@@ -329,6 +329,7 @@ module Redmine
 
   class HelperTest < ActionView::TestCase
     include Redmine::I18n
+    include Propshaft::Helper
 
     def setup
       super
-- 
2.39.2

