mirror of
https://github.com/discourse/discourse.git
synced 2024-11-23 12:40:40 +08:00
FIX: Add missing test
This commit is contained in:
parent
c40ac5abe6
commit
dd0cb6a117
25
spec/components/file_helper_spec.rb
Normal file
25
spec/components/file_helper_spec.rb
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
require 'rails_helper'
|
||||||
|
require 'file_helper'
|
||||||
|
|
||||||
|
describe FileHelper do
|
||||||
|
|
||||||
|
let(:url) { "https://eviltrout.com/trout.png" }
|
||||||
|
let(:png) { Base64.decode64("R0lGODlhAQABALMAAAAAAIAAAACAAICAAAAAgIAAgACAgMDAwICAgP8AAAD/AP//AAAA//8A/wD//wBiZCH5BAEAAA8ALAAAAAABAAEAAAQC8EUAOw==") }
|
||||||
|
|
||||||
|
before do
|
||||||
|
stub_request(:get, url).to_return(body: png)
|
||||||
|
end
|
||||||
|
|
||||||
|
describe "download" do
|
||||||
|
it "returns a file with the image" do
|
||||||
|
tmpfile = FileHelper.download(url, 10000, 'trouttmp')
|
||||||
|
expect(tmpfile.read[0..5]).to eq("GIF89a")
|
||||||
|
end
|
||||||
|
|
||||||
|
it "works with a protocol relative url" do
|
||||||
|
tmpfile = FileHelper.download("//eviltrout.com/trout.png", 10000, 'trouttmp')
|
||||||
|
expect(tmpfile.read[0..5]).to eq("GIF89a")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
Loading…
Reference in New Issue
Block a user