mirror of
https://github.com/neocities/neocities.git
synced 2025-07-20 09:36:00 +02:00
delete nested site_files when directory is deleted
This commit is contained in:
parent
e6aaba74fb
commit
fbe00f6f9c
3 changed files with 23 additions and 4 deletions
|
@ -31,6 +31,20 @@ describe 'site_files' do
|
|||
File.exists?(file_path).must_equal false
|
||||
SiteFile[site_id: @site.id, path: 'test.jpg'].must_be_nil
|
||||
end
|
||||
|
||||
it 'deletes all files in a directory' do
|
||||
upload(
|
||||
'dir' => 'test',
|
||||
'files[]' => Rack::Test::UploadedFile.new('./tests/files/test.jpg', 'image/jpeg')
|
||||
)
|
||||
upload(
|
||||
'dir' => '',
|
||||
'files[]' => Rack::Test::UploadedFile.new('./tests/files/test.jpg', 'image/jpeg')
|
||||
)
|
||||
delete_file filename: 'test'
|
||||
@site.site_files.select {|f| f.path =~ /^test\//}.length.must_equal 0
|
||||
@site.site_files.select {|f| f.path =~ /^test/}.length.must_equal 1
|
||||
end
|
||||
end
|
||||
|
||||
describe 'upload' do
|
||||
|
@ -161,4 +175,4 @@ describe 'site_files' do
|
|||
@site.reload.changed_count.must_equal 2
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue