From b0bb40fe23a8f762c1a9b4208781a65ce2d7ebc9 Mon Sep 17 00:00:00 2001 From: Kyle Drake Date: Thu, 22 Feb 2024 12:30:41 -0600 Subject: [PATCH] fix for cache purge rename --- models/site_file.rb | 3 +++ tests/site_file_tests.rb | 11 +++++++++++ 2 files changed, 14 insertions(+) diff --git a/models/site_file.rb b/models/site_file.rb index 05020187..d4eee0b7 100644 --- a/models/site_file.rb +++ b/models/site_file.rb @@ -116,6 +116,9 @@ class SiteFile < Sequel::Model site.purge_cache site_file.path site.purge_cache original_site_file_path end + else + site.purge_cache new_path + site.purge_cache current_path end end diff --git a/tests/site_file_tests.rb b/tests/site_file_tests.rb index 91b564ef..95c1a490 100644 --- a/tests/site_file_tests.rb +++ b/tests/site_file_tests.rb @@ -29,6 +29,17 @@ describe 'site_files' do PurgeCacheWorker.jobs.clear end + it 'works with html file' do + uploaded_file = Rack::Test::UploadedFile.new('./tests/files/notindex.html', 'text/html') + upload 'files[]' => uploaded_file + PurgeCacheWorker.jobs.clear + testfile = @site.site_files_dataset.where(path: 'notindex.html').first + testfile.rename 'notindex2.html' + _(PurgeCacheWorker.jobs.length).must_equal 2 + _(PurgeCacheWorker.jobs.collect {|p| p['args'].last}.sort).must_equal ["/notindex", "/notindex2"] + end + + it 'renames in same path' do uploaded_file = Rack::Test::UploadedFile.new('./tests/files/test.jpg', 'image/jpeg') upload 'files[]' => uploaded_file