FEATURE: Upload Site Settings. (#6573)

This commit is contained in:
Guo Xiang Tan
2018-11-14 15:03:02 +08:00
committed by GitHub
parent 17bc82765b
commit 44391ee8ab
59 changed files with 892 additions and 244 deletions

View File

@@ -53,5 +53,42 @@ describe Validators::UploadValidator do
end
end
end
describe 'upload for site settings' do
let(:user) { Fabricate(:admin) }
let(:upload) do
Fabricate.build(:upload,
user: user,
original_filename: 'test.ico',
for_site_setting: true
)
end
before do
SiteSetting.authorized_extensions = 'png'
end
describe 'for admin user' do
it 'should allow the upload' do
expect(subject.validate(upload)).to eq(true)
end
describe 'when filename is invalid' do
it 'should not allow the upload' do
upload.original_filename = 'test.txt'
expect(subject.validate(upload)).to eq(nil)
end
end
end
describe 'for normal user' do
let(:user) { Fabricate(:user) }
it 'should not allow the upload' do
expect(subject.validate(upload)).to eq(nil)
end
end
end
end
end