mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
FEATURE: consider SVG as an image when authorized
This commit is contained in:
3
spec/fixtures/images/image.svg
vendored
Normal file
3
spec/fixtures/images/image.svg
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
<svg width="100" height="50">
|
||||
<text x="25" y="25">Discourse</text>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 76 B |
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user