2
0
Fork 0
mirror of https://github.com/discourse/discourse.git synced 2025-09-06 10:50:21 +08:00

FEATURE: consider SVG as an image when authorized

This commit is contained in:
Régis Hanol 2014-11-03 19:54:10 +01:00
parent bab4f48eeb
commit bdb78ce76a
5 changed files with 58 additions and 12 deletions

View file

@ -15,11 +15,15 @@ describe Upload do
let(:user_id) { 1 }
let(:url) { "http://domain.com" }
let(:image) { file_from_fixtures("logo.png") }
let(:image_filename) { "logo.png" }
let(:image) { file_from_fixtures(image_filename) }
let(:image_filesize) { File.size(image) }
let(:image_sha1) { Digest::SHA1.file(image).hexdigest }
let(:image_svg_filename) { "image.svg" }
let(:image_svg) { file_from_fixtures(image_svg_filename) }
let(:image_svg_filesize) { File.size(image_svg) }
let(:attachment_path) { __FILE__ }
let(:attachment) { File.new(attachment_path) }
let(:attachment_filename) { File.basename(attachment_path) }
@ -96,6 +100,27 @@ describe Upload do
upload.url.should == url
end
context "when svg is authorized" do
before { SiteSetting.stubs(:authorized_extensions).returns("svg") }
it "consider SVG as an image" do
store = {}
Discourse.expects(:store).returns(store)
store.expects(:store_upload).returns(url)
upload = Upload.create_for(user_id, image_svg, image_svg_filename, image_svg_filesize)
upload.user_id.should == user_id
upload.original_filename.should == image_svg_filename
upload.filesize.should == image_svg_filesize
upload.width.should == 100
upload.height.should == 50
upload.url.should == url
end
end
end
context ".get_from_url" do