diff options
| author | erdgeist <erdgeist@erdgeist.org> | 2026-07-13 23:29:54 +0200 |
|---|---|---|
| committer | erdgeist <erdgeist@erdgeist.org> | 2026-07-13 23:29:54 +0200 |
| commit | 802e81f8551e10a3f97846a49636e675c7e21cb3 (patch) | |
| tree | e7781b88465cc35f51ea1839d655b6507383a5b7 /test | |
| parent | 0113d895e2fd8bf2cf88ae0196b9ab144ac9350b (diff) | |
Add cache-buster using mtime of css and js files outside the asset pipeline
Diffstat (limited to 'test')
| -rw-r--r-- | test/models/helpers/admin_helper_test.rb | 10 |
1 files changed, 10 insertions, 0 deletions
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 @@ | |||
| 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 | ||
| 4 | end | 14 | end |
