From c824586ee5df378cf6591f039416288f0d969644 Mon Sep 17 00:00:00 2001 From: Jean Boussier Date: Thu, 28 Mar 2024 10:02:19 +0100 Subject: [PATCH 01/11] Fix compatibility with newer Minitest and Rake --- sprockets.gemspec | 2 +- test/sprockets_test.rb | 2 +- test/test_cache_store.rb | 10 +++++----- test/test_closure_compressor.rb | 2 +- test/test_coffee_script_processor.rb | 2 +- test/test_digest_utils.rb | 2 +- test/test_eco_processor.rb | 2 +- test/test_ejs_processor.rb | 2 +- test/test_encoding_utils.rb | 2 +- test/test_erb_processor.rb | 2 +- test/test_http_utils.rb | 2 +- test/test_jst_processor.rb | 2 +- test/test_manifest_utils.rb | 2 +- test/test_path_dependency_utils.rb | 2 +- test/test_path_digest_utils.rb | 2 +- test/test_path_utils.rb | 2 +- test/test_processor_utils.rb | 2 +- test/test_require.rb | 2 +- test/test_uglifier_compressor.rb | 2 +- test/test_uri_utils.rb | 2 +- test/test_utils.rb | 2 +- test/test_yui_compressor.rb | 2 +- 22 files changed, 26 insertions(+), 26 deletions(-) diff --git a/sprockets.gemspec b/sprockets.gemspec index 649e51e0f..ff7a2e729 100644 --- a/sprockets.gemspec +++ b/sprockets.gemspec @@ -23,7 +23,7 @@ Gem::Specification.new do |s| s.add_development_dependency "minitest", "~> 5.0" s.add_development_dependency "nokogiri", "~> 1.3" s.add_development_dependency "rack-test", "~> 0.6" - s.add_development_dependency "rake", "~> 10.0" + s.add_development_dependency "rake" s.add_development_dependency "sass", "~> 3.1" s.add_development_dependency "uglifier", "~> 2.3" s.add_development_dependency "yui-compressor", "~> 0.12" diff --git a/test/sprockets_test.rb b/test/sprockets_test.rb index 306c3cb23..e5102071a 100644 --- a/test/sprockets_test.rb +++ b/test/sprockets_test.rb @@ -125,7 +125,7 @@ def silence_warnings Sprockets.register_transformer 'text/css', 'application/css-sourcemap+json', SourceMapTransformer -class Sprockets::TestCase < MiniTest::Test +class Sprockets::TestCase < Minitest::Test FIXTURE_ROOT = File.expand_path(File.join(File.dirname(__FILE__), "fixtures")) def self.test(name, &block) diff --git a/test/test_cache_store.rb b/test/test_cache_store.rb index b801e869c..4576245a3 100644 --- a/test/test_cache_store.rb +++ b/test/test_cache_store.rb @@ -71,7 +71,7 @@ def test_fetch end end -class TestNullStore < MiniTest::Test +class TestNullStore < Minitest::Test def setup @_store = Sprockets::Cache::NullStore.new @store = Sprockets::Cache.new(Sprockets::Cache::NullStore.new) @@ -85,7 +85,7 @@ def test_inspect include CacheStoreNullTests end -class TestMemoryStore < MiniTest::Test +class TestMemoryStore < Minitest::Test def setup @_store = Sprockets::Cache::MemoryStore.new @store = Sprockets::Cache.new(@_store) @@ -118,7 +118,7 @@ def test_set_with_lru end end -class TestZeroMemoryStore < MiniTest::Test +class TestZeroMemoryStore < Minitest::Test def setup @_store = Sprockets::Cache::MemoryStore.new(0) @store = Sprockets::Cache.new(@_store) @@ -131,7 +131,7 @@ def test_inspect include CacheStoreNullTests end -class TestFileStore < MiniTest::Test +class TestFileStore < Minitest::Test def setup @root = Dir::mktmpdir "sprockets-file-store" @_store = Sprockets::Cache::FileStore.new(@root) @@ -159,7 +159,7 @@ def test_corrupted_read include CacheStoreTests end -class TestZeroFileStore < MiniTest::Test +class TestZeroFileStore < Minitest::Test def setup @tmpdir = Dir::mktmpdir "sprockets-file-store-zero" @_store = Sprockets::Cache::FileStore.new(@tmpdir, 0) diff --git a/test/test_closure_compressor.rb b/test/test_closure_compressor.rb index a758a3701..25ae73668 100644 --- a/test/test_closure_compressor.rb +++ b/test/test_closure_compressor.rb @@ -2,7 +2,7 @@ require 'sprockets/cache' require 'sprockets/closure_compressor' -class TestClosureCompressor < MiniTest::Test +class TestClosureCompressor < Minitest::Test def test_compress_javascript input = { :data => "function foo() {\n return true;\n}", diff --git a/test/test_coffee_script_processor.rb b/test/test_coffee_script_processor.rb index b1c69b257..f4d3bff9f 100644 --- a/test/test_coffee_script_processor.rb +++ b/test/test_coffee_script_processor.rb @@ -2,7 +2,7 @@ require 'sprockets/cache' require 'sprockets/coffee_script_processor' -class TestCoffeeScriptProcessor < MiniTest::Test +class TestCoffeeScriptProcessor < Minitest::Test def test_compile_coffee_script_template_to_js input = { content_type: 'application/javascript', diff --git a/test/test_digest_utils.rb b/test/test_digest_utils.rb index e8e1764c3..5d6d2184a 100644 --- a/test/test_digest_utils.rb +++ b/test/test_digest_utils.rb @@ -1,7 +1,7 @@ require 'minitest/autorun' require 'sprockets/digest_utils' -class TestDigestUtils < MiniTest::Test +class TestDigestUtils < Minitest::Test include Sprockets::DigestUtils def test_detect_digest_class diff --git a/test/test_eco_processor.rb b/test/test_eco_processor.rb index df5c2fbb9..c023fa850 100644 --- a/test/test_eco_processor.rb +++ b/test/test_eco_processor.rb @@ -2,7 +2,7 @@ require 'sprockets/cache' require 'sprockets/eco_processor' -class TestEcoProcessor < MiniTest::Test +class TestEcoProcessor < Minitest::Test def test_compile_eco_template_to_js input = { content_type: 'application/javascript', diff --git a/test/test_ejs_processor.rb b/test/test_ejs_processor.rb index f6f55ad6e..35fb91a33 100644 --- a/test/test_ejs_processor.rb +++ b/test/test_ejs_processor.rb @@ -2,7 +2,7 @@ require 'sprockets/cache' require 'sprockets/ejs_processor' -class TestEjsProcessor < MiniTest::Test +class TestEjsProcessor < Minitest::Test def test_compile_ejs_template_to_js input = { content_type: 'application/javascript', diff --git a/test/test_encoding_utils.rb b/test/test_encoding_utils.rb index 692ffb790..5a03a4658 100644 --- a/test/test_encoding_utils.rb +++ b/test/test_encoding_utils.rb @@ -2,7 +2,7 @@ require 'minitest/autorun' require 'sprockets/encoding_utils' -class TestDigestUtils < MiniTest::Test +class TestDigestUtils < Minitest::Test include Sprockets::EncodingUtils def test_deflate diff --git a/test/test_erb_processor.rb b/test/test_erb_processor.rb index 6c62e5953..062b98517 100644 --- a/test/test_erb_processor.rb +++ b/test/test_erb_processor.rb @@ -3,7 +3,7 @@ require 'sprockets/cache' require 'sprockets/erb_processor' -class TestERBProcessor < MiniTest::Test +class TestERBProcessor < Minitest::Test def uri_path(path) path = '/' + path if path[1] == ':' # Windows path / drive letter diff --git a/test/test_http_utils.rb b/test/test_http_utils.rb index 4523aacf6..a758b5c26 100644 --- a/test/test_http_utils.rb +++ b/test/test_http_utils.rb @@ -1,7 +1,7 @@ require 'minitest/autorun' require 'sprockets/http_utils' -class TestHTTPUtils < MiniTest::Test +class TestHTTPUtils < Minitest::Test include Sprockets::HTTPUtils def test_match_mime_type diff --git a/test/test_jst_processor.rb b/test/test_jst_processor.rb index 26ef248b5..0e5bb7bf2 100644 --- a/test/test_jst_processor.rb +++ b/test/test_jst_processor.rb @@ -2,7 +2,7 @@ require 'sprockets/cache' require 'sprockets/jst_processor' -class TestJstProcessor < MiniTest::Test +class TestJstProcessor < Minitest::Test def test_export_js_template_in_JST input = { name: 'users/show', diff --git a/test/test_manifest_utils.rb b/test/test_manifest_utils.rb index 17753bc8d..6ffc35e76 100644 --- a/test/test_manifest_utils.rb +++ b/test/test_manifest_utils.rb @@ -1,7 +1,7 @@ require 'minitest/autorun' require 'sprockets/manifest_utils' -class TestManifestUtils < MiniTest::Test +class TestManifestUtils < Minitest::Test include Sprockets::ManifestUtils def test_generate_manifest_path diff --git a/test/test_path_dependency_utils.rb b/test/test_path_dependency_utils.rb index 82517d786..0b96394d1 100644 --- a/test/test_path_dependency_utils.rb +++ b/test/test_path_dependency_utils.rb @@ -1,7 +1,7 @@ require 'minitest/autorun' require 'sprockets/path_dependency_utils' -class TestPathDependencyUtils < MiniTest::Test +class TestPathDependencyUtils < Minitest::Test include Sprockets::PathDependencyUtils def test_entries_with_dependencies diff --git a/test/test_path_digest_utils.rb b/test/test_path_digest_utils.rb index 0f5e66571..726c2e1c9 100644 --- a/test/test_path_digest_utils.rb +++ b/test/test_path_digest_utils.rb @@ -1,7 +1,7 @@ require 'minitest/autorun' require 'sprockets/path_digest_utils' -class TestPathDigestUtils < MiniTest::Test +class TestPathDigestUtils < Minitest::Test include Sprockets::PathDigestUtils def test_file_stat_digest diff --git a/test/test_path_utils.rb b/test/test_path_utils.rb index e6362d92d..5d0d52ac8 100644 --- a/test/test_path_utils.rb +++ b/test/test_path_utils.rb @@ -1,7 +1,7 @@ require 'minitest/autorun' require 'sprockets/path_utils' -class TestPathUtils < MiniTest::Test +class TestPathUtils < Minitest::Test include Sprockets::PathUtils DOSISH = File::ALT_SEPARATOR != nil diff --git a/test/test_processor_utils.rb b/test/test_processor_utils.rb index b856de253..4f76b4661 100644 --- a/test/test_processor_utils.rb +++ b/test/test_processor_utils.rb @@ -36,7 +36,7 @@ def test_charset_supersedes_default end end -class TestProcessorUtils < MiniTest::Test +class TestProcessorUtils < Minitest::Test include Sprockets::ProcessorUtils class Processor diff --git a/test/test_require.rb b/test/test_require.rb index ff58ea7b9..59db45f05 100644 --- a/test/test_require.rb +++ b/test/test_require.rb @@ -1,6 +1,6 @@ require 'minitest/autorun' -class TestRequire < MiniTest::Test +class TestRequire < Minitest::Test parallelize_me! ROOT = File.expand_path("../..", __FILE__) diff --git a/test/test_uglifier_compressor.rb b/test/test_uglifier_compressor.rb index 42164c5d5..a566b47cd 100644 --- a/test/test_uglifier_compressor.rb +++ b/test/test_uglifier_compressor.rb @@ -2,7 +2,7 @@ require 'sprockets/cache' require 'sprockets/uglifier_compressor' -class TestUglifierCompressor < MiniTest::Test +class TestUglifierCompressor < Minitest::Test def test_compress_javascript input = { content_type: 'application/javascript', diff --git a/test/test_uri_utils.rb b/test/test_uri_utils.rb index 2c43f0a7e..1c87be754 100644 --- a/test/test_uri_utils.rb +++ b/test/test_uri_utils.rb @@ -1,7 +1,7 @@ require 'minitest/autorun' require 'sprockets/uri_utils' -class TestURIUtils < MiniTest::Test +class TestURIUtils < Minitest::Test include Sprockets::URIUtils DOSISH = File::ALT_SEPARATOR != nil diff --git a/test/test_utils.rb b/test/test_utils.rb index 04a723361..9b998aeb7 100644 --- a/test/test_utils.rb +++ b/test/test_utils.rb @@ -1,7 +1,7 @@ require 'minitest/autorun' require 'sprockets/utils' -class TestUtils < MiniTest::Test +class TestUtils < Minitest::Test include Sprockets::Utils def test_duplicable_pre_ruby_2_4 diff --git a/test/test_yui_compressor.rb b/test/test_yui_compressor.rb index b52ce1375..9225d8900 100644 --- a/test/test_yui_compressor.rb +++ b/test/test_yui_compressor.rb @@ -2,7 +2,7 @@ require 'sprockets/cache' require 'sprockets/yui_compressor' -class TestYUICompressor < MiniTest::Test +class TestYUICompressor < Minitest::Test def test_compress_javascript input = { content_type: 'application/javascript', From 678bc47db3e644c5536f9a5735cad09cf91b344c Mon Sep 17 00:00:00 2001 From: Jean Boussier Date: Thu, 28 Mar 2024 10:03:36 +0100 Subject: [PATCH 02/11] Fix unsused variable warnings --- test/test_asset.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/test_asset.rb b/test/test_asset.rb index 36a5cc6b3..9e07fc57d 100644 --- a/test/test_asset.rb +++ b/test/test_asset.rb @@ -117,7 +117,7 @@ def self.test(name, &block) sandbox filename do write(filename, "a;") - asset = asset('test.js') + assert asset('test.js') File.unlink(filename) @@ -132,7 +132,7 @@ def self.test(name, &block) sandbox main, dep do write(main, "//= depend_on test-dep\n") write(dep, "a;") - asset = asset('test-main.js') + assert asset('test-main.js') File.unlink(dep) From 79994e8b158040adef117e81597cb0ac2a85c20e Mon Sep 17 00:00:00 2001 From: Jean Boussier Date: Thu, 28 Mar 2024 10:04:03 +0100 Subject: [PATCH 03/11] Add dependency on base64 --- sprockets.gemspec | 1 + 1 file changed, 1 insertion(+) diff --git a/sprockets.gemspec b/sprockets.gemspec index ff7a2e729..7f88d1a62 100644 --- a/sprockets.gemspec +++ b/sprockets.gemspec @@ -11,6 +11,7 @@ Gem::Specification.new do |s| s.files = Dir["README.md", "CHANGELOG.md", "LICENSE", "lib/**/*.rb"] s.executables = ["sprockets"] + s.add_dependency "base64" s.add_dependency "rack", "> 1", "< 3" s.add_dependency "concurrent-ruby", "~> 1.0" From 2bd98b8be9113b262aae3c3e993a683f3a9e7753 Mon Sep 17 00:00:00 2001 From: Jean Boussier Date: Thu, 28 Mar 2024 10:04:52 +0100 Subject: [PATCH 04/11] Fix regexp ambiguity warnings --- test/test_resolve.rb | 2 +- test/test_server.rb | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/test/test_resolve.rb b/test/test_resolve.rb index 39017dd9b..89d54d727 100644 --- a/test/test_resolve.rb +++ b/test/test_resolve.rb @@ -260,7 +260,7 @@ def setup uri end - assert_match /#{ random_path }/, error.message + assert_match(/#{ random_path }/, error.message) end def resolve(path, options = {}) diff --git a/test/test_server.rb b/test/test_server.rb index 19921e191..53d63ea7d 100644 --- a/test/test_server.rb +++ b/test/test_server.rb @@ -288,8 +288,8 @@ def app test "re-throw JS exceptions in the browser" do get "/assets/missing_require.js" assert_equal 200, last_response.status - assert_match /Sprockets::FileNotFound: couldn't find file 'notfound' with type 'application\/javascript'/, last_response.body - assert_match /(in #{fixture_path("server/vendor/javascripts/missing_require.js")}:1)/, last_response.body + assert_match(/Sprockets::FileNotFound: couldn't find file 'notfound' with type 'application\/javascript'/, last_response.body) + assert_match(/(in #{fixture_path("server/vendor/javascripts/missing_require.js")}:1)/, last_response.body) end test "display CSS exceptions in the browser" do From 152e6243bedde36c1ed12e29fba2ebaff77a2574 Mon Sep 17 00:00:00 2001 From: Jean Boussier Date: Thu, 28 Mar 2024 10:05:52 +0100 Subject: [PATCH 05/11] Fix a Ruby 3 keyword bug --- test/test_performance.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/test/test_performance.rb b/test/test_performance.rb index 57e34632d..4cfeb2ea4 100644 --- a/test/test_performance.rb +++ b/test/test_performance.rb @@ -22,6 +22,7 @@ def entries(dirname, *args) end original_entries(dirname, *args) end + ruby2_keywords :entries if respond_to?(:ruby2_keywords, true) end class TestPerformance < Sprockets::TestCase From 9981caf2dd8559cc3e513e8514e4f17eefb965b1 Mon Sep 17 00:00:00 2001 From: Jean Boussier Date: Thu, 28 Mar 2024 10:06:47 +0100 Subject: [PATCH 06/11] Fix minitest assert_nil deprecations --- test/test_asset.rb | 10 +++++----- test/test_cache_store.rb | 2 +- test/test_environment.rb | 2 +- test/test_processor_utils.rb | 2 +- test/test_server.rb | 3 ++- 5 files changed, 10 insertions(+), 9 deletions(-) diff --git a/test/test_asset.rb b/test/test_asset.rb index 9e07fc57d..ae21c242a 100644 --- a/test/test_asset.rb +++ b/test/test_asset.rb @@ -215,7 +215,7 @@ def setup end test "charset is nil" do - assert_equal nil, @asset.charset + assert_nil @asset.charset end test "length" do @@ -1312,7 +1312,7 @@ def setup end test "content type" do - assert_equal nil, content_type("empty") + assert_nil content_type("empty") assert_equal "application/javascript", content_type("application.js") assert_equal "text/css", content_type("application.css") @@ -1324,7 +1324,7 @@ def setup assert_equal "text/css", content_type("store.css.erb") assert_equal "text/plain", content_type("files.erb") - assert_equal nil, content_type("store.foo") + assert_nil content_type("store.foo") assert_equal "application/javascript", content_type("application.coffee") assert_equal "text/css", content_type("application.scss") @@ -1347,7 +1347,7 @@ def setup assert_equal "application/javascript", content_type("jquery.ext/form.js") assert_equal "application/javascript", content_type("jquery-coffee.min.coffee") assert_equal "application/javascript", content_type("jquery-custom.min.js.erb") - assert_equal nil, content_type("jquery.js.min") + assert_nil content_type("jquery.js.min") assert_equal "application/javascript", content_type("all.coffee/plain.js") assert_equal "application/javascript", content_type("all.coffee/hot.coffee") @@ -1357,7 +1357,7 @@ def setup assert_equal "application/javascript", content_type("bar-ng.ngt.haml") assert_equal "application/javascript", content_type("baz-ng.js.ngt") - assert_equal nil, content_type("sprite.css.embed") + assert_nil content_type("sprite.css.embed") assert_equal "application/javascript", content_type("traceur.es6") assert_equal "application/javascript", content_type("traceur.js.es6") diff --git a/test/test_cache_store.rb b/test/test_cache_store.rb index 4576245a3..df09740c4 100644 --- a/test/test_cache_store.rb +++ b/test/test_cache_store.rb @@ -62,7 +62,7 @@ def test_delete @store.set("foo", "bar") assert_equal "bar", @store.get("foo") @store.set("foo", nil) - assert_equal nil, @store.get("foo") + assert_nil @store.get("foo") end def test_fetch diff --git a/test/test_environment.rb b/test/test_environment.rb index 79b8b6480..30f7d93cf 100644 --- a/test/test_environment.rb +++ b/test/test_environment.rb @@ -361,7 +361,7 @@ def self.test(name, &block) end test "missing asset returns nil" do - assert_equal nil, @env["missing.js"] + assert_nil @env["missing.js"] end test "missing asset path returns nil" do diff --git a/test/test_processor_utils.rb b/test/test_processor_utils.rb index 4f76b4661..727b7b5ef 100644 --- a/test/test_processor_utils.rb +++ b/test/test_processor_utils.rb @@ -19,7 +19,7 @@ def test_charset_supersedes_default_when_nil end @env.register_processor('image/png' , processor) asset = @env['troll.png'] - assert_equal nil, asset.charset + assert_nil asset.charset ensure @env.unregister_preprocessor('image/png' , processor) end diff --git a/test/test_server.rb b/test/test_server.rb index 53d63ea7d..8446e2c7a 100644 --- a/test/test_server.rb +++ b/test/test_server.rb @@ -112,7 +112,8 @@ def app # Allow 304 headers assert_equal cache_control, last_response.headers['Cache-Control'] assert_equal etag, last_response.headers['ETag'] - assert_equal expires, last_response.headers['Expires'] + assert_nil expires + assert_nil last_response.headers['Expires'] assert_equal vary, last_response.headers['Vary'] # Disallowed 304 headers From 5c74bbfbb89f416c4771d4ebfb3678e852a6f4d7 Mon Sep 17 00:00:00 2001 From: Jean Boussier Date: Thu, 28 Mar 2024 10:11:48 +0100 Subject: [PATCH 07/11] Fix URIUills.split_file_uri compatibility with newer URI gem --- lib/sprockets/uri_utils.rb | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/sprockets/uri_utils.rb b/lib/sprockets/uri_utils.rb index 3ff51c38d..605d956db 100644 --- a/lib/sprockets/uri_utils.rb +++ b/lib/sprockets/uri_utils.rb @@ -50,6 +50,9 @@ def split_file_uri(uri) # Hack for parsing Windows "file:///C:/Users/IEUser" paths path.gsub!(/^\/([a-zA-Z]:)/, '\1'.freeze) + host = nil if host && host.empty? + query = nil if query && query.empty? + [scheme, host, path, query] end From f4218ad99cc9879439efc5d0a559d724d1fce53d Mon Sep 17 00:00:00 2001 From: Jean Boussier Date: Thu, 28 Mar 2024 10:12:01 +0100 Subject: [PATCH 08/11] Fix a method redefinition warning --- test/test_utils.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/test/test_utils.rb b/test/test_utils.rb index 9b998aeb7..42df3be44 100644 --- a/test/test_utils.rb +++ b/test/test_utils.rb @@ -192,6 +192,7 @@ def bar def foo 1 end + alias_method :foo, :foo end module ScopedFunctions From 35350e29b7b08bcd0ca4f8d93aad87d6599eab4f Mon Sep 17 00:00:00 2001 From: Jean Boussier Date: Thu, 28 Mar 2024 10:22:20 +0100 Subject: [PATCH 09/11] Fix frozen string literal compatibility issues NB: the Sass tests are just skipped because that gem won't ever be compatible. --- lib/sprockets.rb | 2 +- lib/sprockets/directive_processor.rb | 2 ++ lib/sprockets/server.rb | 4 ++-- lib/sprockets/utils.rb | 1 + test/test_asset.rb | 2 ++ test/test_digest_utils.rb | 2 +- test/test_encoding.rb | 1 + test/test_sass.rb | 2 ++ 8 files changed, 12 insertions(+), 4 deletions(-) diff --git a/lib/sprockets.rb b/lib/sprockets.rb index 5f0b0c7b2..42d25a5f1 100644 --- a/lib/sprockets.rb +++ b/lib/sprockets.rb @@ -105,7 +105,7 @@ module Sprockets register_bundle_processor 'application/javascript', Bundle register_bundle_processor 'text/css', Bundle - register_bundle_metadata_reducer '*/*', :data, proc { "" }, :concat + register_bundle_metadata_reducer '*/*', :data, proc { "" }, :+ register_bundle_metadata_reducer 'application/javascript', :data, proc { "" }, Utils.method(:concat_javascript_sources) register_bundle_metadata_reducer '*/*', :links, :+ diff --git a/lib/sprockets/directive_processor.rb b/lib/sprockets/directive_processor.rb index f4680c4bb..fd0f16dce 100644 --- a/lib/sprockets/directive_processor.rb +++ b/lib/sprockets/directive_processor.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: false + require 'set' require 'shellwords' diff --git a/lib/sprockets/server.rb b/lib/sprockets/server.rb index 2ad2c9abd..15c01ba57 100644 --- a/lib/sprockets/server.rb +++ b/lib/sprockets/server.rb @@ -251,11 +251,11 @@ def cache_headers(env, etag) # If the request url contains a fingerprint, set a long # expires on the response if path_fingerprint(env["PATH_INFO"]) - headers["Cache-Control"] << ", max-age=31536000" + headers["Cache-Control"] += ", max-age=31536000" # Otherwise set `must-revalidate` since the asset could be modified. else - headers["Cache-Control"] << ", must-revalidate" + headers["Cache-Control"] += ", must-revalidate" headers["Vary"] = "Accept-Encoding" end diff --git a/lib/sprockets/utils.rb b/lib/sprockets/utils.rb index 11ff9443e..114723cea 100644 --- a/lib/sprockets/utils.rb +++ b/lib/sprockets/utils.rb @@ -102,6 +102,7 @@ def string_end_with_semicolon?(str) # # Returns buf String. def concat_javascript_sources(buf, source) + buf = +buf if source.bytesize > 0 buf << source diff --git a/test/test_asset.rb b/test/test_asset.rb index ae21c242a..52fc51dc0 100644 --- a/test/test_asset.rb +++ b/test/test_asset.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: false + require "sprockets_test" module AssetTests diff --git a/test/test_digest_utils.rb b/test/test_digest_utils.rb index 5d6d2184a..8f0b1e42b 100644 --- a/test/test_digest_utils.rb +++ b/test/test_digest_utils.rb @@ -35,7 +35,7 @@ def test_digest assert_equal "62427aa539a0b78e90fd710dc0e15f2960771ba44214b5d41d4a93a8b2940a38", hexdigest({"foo" => "baz"}) assert_equal "b6054efd9929004bdd0a1c09eb2d12961325396da749143def3e9a4050aa703e", hexdigest([[:foo, 1]]) assert_equal "79a19ffe41ecebd5dc35e95363e0b4aa79b139a22bc650384df57eb09842f099", hexdigest([{:foo => 1}]) - assert_equal "94ee40cca7c2c6d2a134033d2f5a31c488cad5d3dcc61a3dbb5e2a858635874b", hexdigest("foo".force_encoding('UTF-8').encoding) + assert_equal "94ee40cca7c2c6d2a134033d2f5a31c488cad5d3dcc61a3dbb5e2a858635874b", hexdigest(Encoding::UTF_8) assert_raises(TypeError) do digest(Object.new) diff --git a/test/test_encoding.rb b/test/test_encoding.rb index 5e9e940b2..1115771ab 100644 --- a/test/test_encoding.rb +++ b/test/test_encoding.rb @@ -1,4 +1,5 @@ # encoding: utf-8 +# frozen_string_literal: false require "sprockets_test" class AssetEncodingTest < Sprockets::TestCase diff --git a/test/test_sass.rb b/test/test_sass.rb index 6c6a38a88..500fa91a5 100644 --- a/test/test_sass.rb +++ b/test/test_sass.rb @@ -1,5 +1,7 @@ require 'sprockets_test' +return if "test".frozen? # The sass gem isn't frozen string literal compatible + silence_warnings do require 'sass' end From 086c8baace07c3410a92df4b5aa51c43c377d8a8 Mon Sep 17 00:00:00 2001 From: Jean Boussier Date: Thu, 28 Mar 2024 10:29:04 +0100 Subject: [PATCH 10/11] Setup GitHub Actions --- .github/workflows/ci.yml | 34 ++++++++++++++++++++++++++++++++ .github/workflows/isolated.yml | 20 +++++++++++++++++++ .travis.yml | 36 ---------------------------------- 3 files changed, 54 insertions(+), 36 deletions(-) create mode 100644 .github/workflows/ci.yml create mode 100644 .github/workflows/isolated.yml delete mode 100644 .travis.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 000000000..7d519f4b2 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,34 @@ +name: CI +on: [push, pull_request] +jobs: + tests: + runs-on: ubuntu-latest + continue-on-error: ${{ matrix.experimental }} + name: ${{ matrix.ruby }} + strategy: + matrix: + experimental: [false] + ruby: + - "2.5" + - "2.6" + - "2.7" + - "3.0" + - "3.1" + - "3.2" + - "3.3" + rubyopt: [""] + include: + - { ruby: "3.3", rubyopt: "--enable-frozen-string-literal --debug-frozen-string-literal", experimental: false } + - { ruby: head, experimental: true } + + steps: + - uses: actions/checkout@v4 + - name: Set up Ruby + uses: ruby/setup-ruby@v1 + with: + ruby-version: ${{ matrix.ruby }} + bundler-cache: true + + - name: Run tests ${{ matrix.rubyopt }} + timeout-minutes: 10 + run: bundle exec rake RUBYOPT="${{ matrix.rubyopt }}" diff --git a/.github/workflows/isolated.yml b/.github/workflows/isolated.yml new file mode 100644 index 000000000..b617dac4f --- /dev/null +++ b/.github/workflows/isolated.yml @@ -0,0 +1,20 @@ +name: CI isolated tests +on: [push, pull_request] +jobs: + tests: + runs-on: ubuntu-latest + strategy: + matrix: + ruby: [2.7] + + steps: + - uses: actions/checkout@v3 + + - name: Set up Ruby + uses: ruby/setup-ruby@v1 + with: + ruby-version: ${{ matrix.ruby }} + bundler-cache: true + + - name: Run tests + run: bundle exec rake test_isolated diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index d9c9b8027..000000000 --- a/.travis.yml +++ /dev/null @@ -1,36 +0,0 @@ -language: ruby - -cache: bundler - -sudo: false - -rvm: - - 2.0.0 - - 2.1 - - 2.2 - - 2.3.1 - - 2.4.0-rc1 - -matrix: - include: - test_isolated - -matrix: - include: - - rvm: 1.9.3 - gemfile: gemfiles/Gemfile-1.9 - - rvm: 2.2 - script: bundle exec rake test_isolated - -notifications: - email: false - irc: - on_success: change - on_failure: always - channels: - - "irc.freenode.org#rails-contrib" - campfire: - on_success: change - on_failure: always - rooms: - - secure: "bJyiK4EXGfm0EhAId/QqIEdhPCx8BjxUKvx1h0+wgrsUm8BDoEN7tg2wqoGWU2KfzqLdx77wZVQXbmksOgmNcMGKJed5uNNMpAG4B+AQYTEX0odFRgOZKdkMtypga9CNIkKVgeSKhd6BY+g2AV6wvJ0Jq056uXpGkqK5OEFOpQc=" From 45886abcbdb487cc4bffb97dcb7beb60b41eff2a Mon Sep 17 00:00:00 2001 From: Jean Boussier Date: Thu, 28 Mar 2024 10:40:54 +0100 Subject: [PATCH 11/11] Skip TestRequire on CI and older rubies --- test/test_require.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/test_require.rb b/test/test_require.rb index 59db45f05..e6ed2e9c8 100644 --- a/test/test_require.rb +++ b/test/test_require.rb @@ -1,5 +1,7 @@ require 'minitest/autorun' +return if ENV["CI"] && RUBY_VERSION < "3.2" # Not working on CI for unknown reason + class TestRequire < Minitest::Test parallelize_me!