Update tests for screenshot worker url array

This commit is contained in:
Kyle Drake 2020-01-27 01:22:57 -08:00
parent eb519d0bbf
commit 368d000551
2 changed files with 9 additions and 3 deletions

View file

@ -16,7 +16,8 @@ proxy_ips:
education_tag_whitelist:
- mrteacher
stop_forum_spam_api_key: testkey
screenshots_url: http://screenshots:derp@screenshotssite.com
screenshot_urls:
- http://screenshots:derp@screenshotssite.com
cache_control_ips:
- 1.2.3.4
- 4.5.6.7

View file

@ -4,10 +4,15 @@ describe ScreenshotWorker do
it 'saves a screenshot for a root html file' do
['index.html', 'derpie/derp/index.html'].each do |path|
uri = Addressable::URI.parse $config['screenshots_url']
uri = Addressable::URI.parse $config['screenshot_urls'].sample
site = Fabricate :site
stub_request(:get, "#{uri.scheme}://#{uri.host}/?url=#{site.uri}/#{path}&wait_time=#{ScreenshotWorker::PAGE_WAIT_TIME}").
base_host = "#{uri.scheme}://#{uri.host}"
if uri.port != 80 && uri.port != 443
base_host += ":#{uri.port}"
end
stub_request(:get, "#{base_host}/?url=#{site.uri}/#{path}&wait_time=#{ScreenshotWorker::PAGE_WAIT_TIME}").
with(basic_auth: [uri.user, uri.password]).
to_return(status: 200, headers: {}, body: File.read('tests/files/img/test.jpg'))