]> source.dussan.org Git - redmine.git/commitdiff
Fix tests after asset pipeline implementation (#39111).
authorMarius Balteanu <marius.balteanu@zitec.com>
Thu, 25 Jan 2024 05:41:50 +0000 (05:41 +0000)
committerMarius Balteanu <marius.balteanu@zitec.com>
Thu, 25 Jan 2024 05:41:50 +0000 (05:41 +0000)
Patch by Takashi Kato (@tohosaku).

git-svn-id: https://svn.redmine.org/redmine/trunk@22628 e93f8b46-1217-0410-a6f0-8f06a7374b81

test/helpers/application_helper_test.rb
test/helpers/avatars_helper_test.rb
test/integration/layout_test.rb
test/integration/lib/redmine/hook_test.rb
test/integration/lib/redmine/themes_test.rb
test/test_helper.rb

index 82b1c32782502f0261fc07c3221e33266dd4652d..2642688d6c5b367452e602df7255f42595d44157 100644 (file)
@@ -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
index ab28a6d6546155c20c03d4eb05d74cf39485e7b4..cc74a47df8efdd4940894fea3c2795b964564afb 100644 (file)
@@ -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
index 662ca55ca7f898747e34e208273ac32e32d889c5..b6112ff8758fc62b0eda32a06f970a740be8aaa7 100644 (file)
@@ -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
 
index e7f2fa35aa0de273b9e28391a3836849c5eb0c92..13d154677b5c49fb5a0775fcb8b998c244ae9d9b 100644 (file)
@@ -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
index f7434468f8c5a58ee7bdf17b74474839f915e9ef..d058df830888c2de32ef06b33b5aae0cd38d6ad7 100644 (file)
@@ -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
index 23ba199faa82c86442ae14f0e0f686854be604b0..e64407945e649525f9ee9ddd93d82cd72211b5d3 100644 (file)
@@ -334,6 +334,7 @@ module Redmine
 
   class HelperTest < ActionView::TestCase
     include Redmine::I18n
+    include Propshaft::Helper
 
     def setup
       super