diff options
| author | erdgeist <erdgeist@erdgeist.org> | 2026-07-14 16:52:03 +0200 |
|---|---|---|
| committer | erdgeist <erdgeist@erdgeist.org> | 2026-07-14 16:53:15 +0200 |
| commit | ffb3c9987c2f820b99e8ad0ad56db8ae0324671c (patch) | |
| tree | 5f8ae79e6952cc6808ba5d5f827c98b6c78b62df /test | |
| parent | c7ed30918154d801c44f77645ead38d4759d2778 (diff) | |
Extend static-asset cache-busting to the public layout
mtime_busted_path only ever covered the four admin-only static
files. The public layout has the identical exposure -- ccc.css,
glightbox's vendored CSS/JS, and public.js are all served straight
from public/ with no pipeline fingerprinting either -- just never
got the same treatment.
Diffstat (limited to 'test')
| -rw-r--r-- | test/models/helpers/admin_helper_test.rb | 10 | ||||
| -rw-r--r-- | test/models/helpers/application_helper_test.rb | 14 |
2 files changed, 14 insertions, 10 deletions
diff --git a/test/models/helpers/admin_helper_test.rb b/test/models/helpers/admin_helper_test.rb index 94e9861..23d9f40 100644 --- a/test/models/helpers/admin_helper_test.rb +++ b/test/models/helpers/admin_helper_test.rb | |||
| @@ -1,14 +1,4 @@ | |||
| 1 | require 'test_helper' | 1 | require 'test_helper' |
| 2 | 2 | ||
| 3 | class AdminHelperTest < ActionView::TestCase | 3 | class AdminHelperTest < ActionView::TestCase |
| 4 | test "mtime_busted_path appends the file's real mtime as a query param" do | ||
| 5 | path = "/stylesheets/admin.css" | ||
| 6 | expected_mtime = File.mtime(Rails.public_path.join("stylesheets/admin.css")).to_i | ||
| 7 | |||
| 8 | assert_equal "#{path}?v=#{expected_mtime}", mtime_busted_path(path) | ||
| 9 | end | ||
| 10 | |||
| 11 | test "mtime_busted_path raises clearly for a missing file rather than silently omitting the version" do | ||
| 12 | assert_raises(RuntimeError) { mtime_busted_path("/stylesheets/does_not_exist.css") } | ||
| 13 | end | ||
| 14 | end | 4 | end |
diff --git a/test/models/helpers/application_helper_test.rb b/test/models/helpers/application_helper_test.rb new file mode 100644 index 0000000..56096a5 --- /dev/null +++ b/test/models/helpers/application_helper_test.rb | |||
| @@ -0,0 +1,14 @@ | |||
| 1 | require 'test_helper' | ||
| 2 | |||
| 3 | class ApplicationHelperTest < ActionView::TestCase | ||
| 4 | test "mtime_busted_path appends the file's real mtime as a query param" do | ||
| 5 | path = "/stylesheets/admin.css" | ||
| 6 | expected_mtime = File.mtime(Rails.public_path.join("stylesheets/admin.css")).to_i | ||
| 7 | |||
| 8 | assert_equal "#{path}?v=#{expected_mtime}", mtime_busted_path(path) | ||
| 9 | end | ||
| 10 | |||
| 11 | test "mtime_busted_path raises clearly for a missing file rather than silently omitting the version" do | ||
| 12 | assert_raises(RuntimeError) { mtime_busted_path("/stylesheets/does_not_exist.css") } | ||
| 13 | end | ||
| 14 | end | ||
