mirror of
https://github.com/discourse/discourse.git
synced 2025-05-21 18:12:32 +08:00
add server-side filesize check on uploads
This commit is contained in:
@ -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
|
||||
|
Reference in New Issue
Block a user