delete nested site_files when directory is deleted

This commit is contained in:
Kyle Drake 2015-02-13 11:54:18 -08:00
parent e6aaba74fb
commit fbe00f6f9c
3 changed files with 23 additions and 4 deletions

View file

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