FIX: Check that the node has a src attr when getting size (#19696)

This commit is contained in:
Roman Rizzi
2023-01-03 15:27:05 -03:00
committed by GitHub
parent b4adb806e5
commit c2e18c41a3
2 changed files with 9 additions and 2 deletions

View File

@ -870,10 +870,17 @@ RSpec.describe CookedPostProcessor do
let(:post) { build(:post) }
let(:cpp) { CookedPostProcessor.new(post) }
let(:image_sizes) do
{ "http://my.discourse.org/image.png" => { "width" => 111, "height" => 222 } }
end
it "returns the size" do
image_sizes = { "http://my.discourse.org/image.png" => { "width" => 111, "height" => 222 } }
expect(cpp.get_size_from_image_sizes("/image.png", image_sizes)).to eq([111, 222])
end
it "returns nil whe img node has no src" do
expect(cpp.get_size_from_image_sizes(nil, image_sizes)).to eq(nil)
end
end
describe "#get_size" do