DEV: Fix flaky twitter onebox behavior (#18141)

The order in which Onebox engines are loaded is not guaranteed. Occasionally during tests, the twitter engine would be loaded before the instagram engine, and cause the Instagram Onebox spec to fail due to the lack of `Onebox.options.twitter_client`.

This commit makes the load order of Onebox engines consistent, and fixes the issue in the twitter_status_onebox.
This commit is contained in:
David Taylor 2022-08-31 01:42:55 +01:00 committed by GitHub
parent 2595e368b1
commit 2e00d4d024
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 2 deletions

View File

@ -9,7 +9,7 @@ module Onebox
def self.engines
constants.select do |constant|
constant.to_s =~ /Onebox$/
end.map(&method(:const_get))
end.sort.map(&method(:const_get))
end
def self.all_iframe_origins

View File

@ -11,7 +11,8 @@ module Onebox
always_https
def self.===(other)
!Onebox.options.twitter_client.twitter_credentials_missing? && super
client = Onebox.options.twitter_client
client && !client.twitter_credentials_missing? && super
end
def http_params