From 802e81f8551e10a3f97846a49636e675c7e21cb3 Mon Sep 17 00:00:00 2001 From: erdgeist Date: Mon, 13 Jul 2026 23:29:54 +0200 Subject: Add cache-buster using mtime of css and js files outside the asset pipeline --- test/models/helpers/admin_helper_test.rb | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'test') diff --git a/test/models/helpers/admin_helper_test.rb b/test/models/helpers/admin_helper_test.rb index 23d9f40..94e9861 100644 --- a/test/models/helpers/admin_helper_test.rb +++ b/test/models/helpers/admin_helper_test.rb @@ -1,4 +1,14 @@ require 'test_helper' class AdminHelperTest < ActionView::TestCase + test "mtime_busted_path appends the file's real mtime as a query param" do + path = "/stylesheets/admin.css" + expected_mtime = File.mtime(Rails.public_path.join("stylesheets/admin.css")).to_i + + assert_equal "#{path}?v=#{expected_mtime}", mtime_busted_path(path) + end + + test "mtime_busted_path raises clearly for a missing file rather than silently omitting the version" do + assert_raises(RuntimeError) { mtime_busted_path("/stylesheets/does_not_exist.css") } + end end -- cgit v1.3