mirror of
https://github.com/neocities/neocities.git
synced 2025-04-24 17:22:35 +02:00
Fix for nonstandard file rename with supporter accounts
This commit is contained in:
parent
fea2ec55f9
commit
f5613d2776
2 changed files with 15 additions and 1 deletions
|
@ -56,7 +56,9 @@ class SiteFile < Sequel::Model
|
|||
mime_type = Magic.guess_file_mime_type site.files_path(self.path)
|
||||
extname = File.extname new_path
|
||||
|
||||
return false, 'unsupported file type' unless site.class.valid_file_mime_type_and_ext?(mime_type, extname)
|
||||
unless site.supporter? || site.class.valid_file_mime_type_and_ext?(mime_type, extname)
|
||||
return false, 'unsupported file type'
|
||||
end
|
||||
end
|
||||
|
||||
begin
|
||||
|
|
|
@ -51,6 +51,18 @@ describe 'site_files' do
|
|||
@site.site_files_dataset.where(path: 'test.jpg').first.wont_equal nil
|
||||
end
|
||||
|
||||
it 'renames nonstandard file type for supporters' do
|
||||
no_file_restriction_plans = Site::PLAN_FEATURES.select {|p,v| v[:no_file_restrictions] == true}
|
||||
no_file_restriction_plans.each do |plan_type,hash|
|
||||
@site = Fabricate :site, plan_type: plan_type
|
||||
upload 'files[]' => Rack::Test::UploadedFile.new('./tests/files/flowercrime.wav', 'audio/x-wav')
|
||||
testfile = @site.site_files_dataset.where(path: 'flowercrime.wav').first
|
||||
res = testfile.rename('flowercrime.exe')
|
||||
res.first.must_equal true
|
||||
File.exists?(@site.files_path('flowercrime.exe')).must_equal true
|
||||
@site.site_files_dataset.where(path: 'flowercrime.exe').first.wont_equal nil
|
||||
end
|
||||
end
|
||||
|
||||
it 'works for directory' do
|
||||
@site.create_directory 'dirone'
|
||||
|
|
Loading…
Add table
Reference in a new issue