mirror of
https://github.com/discourse/discourse.git
synced 2025-05-31 06:49:30 +08:00
FIX: Don’t display error if only error is a missing image (#12216)
`Onebox.preview` can return 0-to-n errors, where the errors are missing OpenGraph attributes (e.g. title, description, image, etc.). If any of these attributes are missing, we construct an error message and attach it to the Oneboxer preview HTML. The error message is something like: “Sorry, we were unable to generate a preview for this web page, because the following oEmbed / OpenGraph tags could not be found: description, image” However, if the only missing tag is `image` we don’t need to display the error, as we have enough other data (title, description, etc.) to construct a useful/complete Onebox.
This commit is contained in:
@ -272,6 +272,12 @@ describe Oneboxer do
|
||||
expect(Oneboxer.preview(url, invalidate_oneboxes: true)).to include("could not be found: description, image")
|
||||
end
|
||||
|
||||
it 'handles a missing image' do
|
||||
# Note: If the only error is a missing image, we shouldn't return an error
|
||||
stub_request(:get, url).to_return(body: response("missing_image"))
|
||||
expect(Oneboxer.preview(url, invalidate_oneboxes: true)).not_to include("could not be found")
|
||||
end
|
||||
|
||||
it 'video with missing description returns a placeholder' do
|
||||
stub_request(:get, url).to_return(body: response("video_missing_description"))
|
||||
expect(Oneboxer.preview(url, invalidate_oneboxes: true)).to include("onebox-placeholder-container")
|
||||
|
Reference in New Issue
Block a user