Fix linting.
This commit is contained in:
parent
16c0ebe8a8
commit
010fe479cb
|
@ -52,27 +52,31 @@ describe FileHelper do
|
||||||
end
|
end
|
||||||
|
|
||||||
it "returns a file with the image" do
|
it "returns a file with the image" do
|
||||||
tmpfile = FileHelper.download(
|
begin
|
||||||
url,
|
tmpfile = FileHelper.download(
|
||||||
max_file_size: 10000,
|
url,
|
||||||
tmp_file_name: 'trouttmp'
|
max_file_size: 10000,
|
||||||
)
|
tmp_file_name: 'trouttmp'
|
||||||
|
)
|
||||||
|
|
||||||
expect(Base64.encode64(tmpfile.read)).to eq(Base64.encode64(png))
|
expect(Base64.encode64(tmpfile.read)).to eq(Base64.encode64(png))
|
||||||
ensure
|
ensure
|
||||||
tmpfile&.close
|
tmpfile&.close
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
it "works with a protocol relative url" do
|
it "works with a protocol relative url" do
|
||||||
tmpfile = FileHelper.download(
|
begin
|
||||||
"//eviltrout.com/trout.png",
|
tmpfile = FileHelper.download(
|
||||||
max_file_size: 10000,
|
"//eviltrout.com/trout.png",
|
||||||
tmp_file_name: 'trouttmp'
|
max_file_size: 10000,
|
||||||
)
|
tmp_file_name: 'trouttmp'
|
||||||
|
)
|
||||||
|
|
||||||
expect(Base64.encode64(tmpfile.read)).to eq(Base64.encode64(png))
|
expect(Base64.encode64(tmpfile.read)).to eq(Base64.encode64(png))
|
||||||
ensure
|
ensure
|
||||||
tmpfile&.close
|
tmpfile&.close
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'when max_file_size is exceeded' do
|
describe 'when max_file_size is exceeded' do
|
||||||
|
@ -87,16 +91,18 @@ describe FileHelper do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'is able to retain the tmpfile' do
|
it 'is able to retain the tmpfile' do
|
||||||
tmpfile = FileHelper.download(
|
begin
|
||||||
"//eviltrout.com/trout.png",
|
tmpfile = FileHelper.download(
|
||||||
max_file_size: 1,
|
"//eviltrout.com/trout.png",
|
||||||
tmp_file_name: 'trouttmp',
|
max_file_size: 1,
|
||||||
retain_on_max_file_size_exceeded: true
|
tmp_file_name: 'trouttmp',
|
||||||
)
|
retain_on_max_file_size_exceeded: true
|
||||||
|
)
|
||||||
|
|
||||||
expect(tmpfile.closed?).to eq(false)
|
expect(tmpfile.closed?).to eq(false)
|
||||||
ensure
|
ensure
|
||||||
tmpfile&.close
|
tmpfile&.close
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -104,19 +110,21 @@ describe FileHelper do
|
||||||
let(:url) { "https://eviltrout.com/trout.jpg" }
|
let(:url) { "https://eviltrout.com/trout.jpg" }
|
||||||
|
|
||||||
it "should prioritize the content type returned by the response" do
|
it "should prioritize the content type returned by the response" do
|
||||||
stub_request(:get, url).to_return(body: png, headers: {
|
begin
|
||||||
"content-type": "image/png"
|
stub_request(:get, url).to_return(body: png, headers: {
|
||||||
})
|
"content-type": "image/png"
|
||||||
|
})
|
||||||
|
|
||||||
tmpfile = FileHelper.download(
|
tmpfile = FileHelper.download(
|
||||||
url,
|
url,
|
||||||
max_file_size: 10000,
|
max_file_size: 10000,
|
||||||
tmp_file_name: 'trouttmp'
|
tmp_file_name: 'trouttmp'
|
||||||
)
|
)
|
||||||
|
|
||||||
expect(File.extname(tmpfile)).to eq('.png')
|
expect(File.extname(tmpfile)).to eq('.png')
|
||||||
ensure
|
ensure
|
||||||
tmpfile&.close
|
tmpfile&.close
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue