mirror of
https://github.com/discourse/discourse.git
synced 2025-06-04 23:36:11 +08:00
FIX: Disable Twitter onebox without API support (#17519)
Twitter removed OpenGraph tags from their pages. We can no longer extract all the information (for example, the quoted tweet) we need to render Oneboxes without using their API.
This commit is contained in:
@ -508,6 +508,29 @@ RSpec.describe Oneboxer do
|
||||
end
|
||||
end
|
||||
|
||||
describe 'Twitter' do
|
||||
let(:url) { 'https://twitter.com/discourse/status/1428031057186627589' }
|
||||
|
||||
before do
|
||||
SiteSetting.twitter_consumer_key = 'twitter_consumer_key'
|
||||
SiteSetting.twitter_consumer_secret = 'twitter_consumer_secret'
|
||||
end
|
||||
|
||||
it 'works with rate limit' do
|
||||
stub_request(:head, "https://twitter.com/discourse/status/1428031057186627589")
|
||||
.to_return(status: 200, body: "", headers: {})
|
||||
|
||||
stub_request(:get, "https://twitter.com/discourse/status/1428031057186627589")
|
||||
.to_return(status: 200, body: "", headers: {})
|
||||
|
||||
stub_request(:post, "https://api.twitter.com/oauth2/token")
|
||||
.to_return(status: 200, body: "{access_token: 'token'}", headers: {})
|
||||
|
||||
expect(Oneboxer.preview(url, invalidate_oneboxes: true)).to eq('')
|
||||
expect(Oneboxer.onebox(url, invalidate_oneboxes: true)).to eq('')
|
||||
end
|
||||
end
|
||||
|
||||
describe '#apply' do
|
||||
it 'generates valid HTML' do
|
||||
raw = "Before Onebox\nhttps://example.com\nAfter Onebox"
|
||||
|
Reference in New Issue
Block a user