add server-side filesize check on uploads

This commit is contained in:
Régis Hanol
2013-07-24 00:54:18 +02:00
parent 75491d2cf6
commit be9217d4c8
34 changed files with 114 additions and 97 deletions

View File

@ -41,13 +41,29 @@ describe UploadsController do
context 'when authorized' do
before { SiteSetting.stubs(:authorized_extensions).returns(".txt") }
before { SiteSetting.stubs(:authorized_extensions).returns(".png|.txt") }
it 'is successful' do
it 'is successful with an image' do
xhr :post, :create, file: logo
response.status.should eq 200
end
it 'is successful with an attachment' do
xhr :post, :create, file: text_file
response.status.should eq 200
end
context 'with a big file' do
before { SiteSetting.stubs(:max_attachment_size_kb).returns(1) }
it 'rejects the upload' do
xhr :post, :create, file: text_file
response.status.should eq 413
end
end
end
context 'when not authorized' do