fix for cache purge rename

This commit is contained in:
Kyle Drake 2024-02-22 12:30:41 -06:00
parent f7341f5a51
commit b0bb40fe23
2 changed files with 14 additions and 0 deletions

View file

@ -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

View file

@ -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