DEV: Add spec for removing and re-adding hotlinked images

Before the recent refactor, this would fail. https://meta.discourse.org/t/154184
This commit is contained in:
David Taylor 2020-08-06 10:01:53 +01:00
parent 2193d02433
commit df39e372d7
No known key found for this signature in database
GPG Key ID: 46904C18B1D3F434

View File

@ -74,6 +74,25 @@ describe Jobs::PullHotlinkedImages do
expect(post.post_uploads.count).to eq(0)
end
it 'replaces images again after edit' do
post = Fabricate(:post, raw: "<img src='#{image_url}'>")
expect do
post.rebake!
end.to change { Upload.count }.by(1)
expect(post.reload.raw).to eq("![](#{Upload.last.short_url})")
# Post raw is updated back to the old value (e.g. by wordpress integration)
post.update(raw: "<img src='#{image_url}'>")
expect do
post.rebake!
end.to change { Upload.count }.by(0) # We alread have the upload
expect(post.reload.raw).to eq("![](#{Upload.last.short_url})")
end
it 'replaces encoded image urls' do
post = Fabricate(:post, raw: "<img src='#{encoded_image_url}'>")
expect do