diff --git a/config.yml.travis b/config.yml.travis index 89cbba9f..b3826b9d 100644 --- a/config.yml.travis +++ b/config.yml.travis @@ -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 diff --git a/tests/workers/screenshot_worker_tests.rb b/tests/workers/screenshot_worker_tests.rb index 268679cb..0dc97d53 100644 --- a/tests/workers/screenshot_worker_tests.rb +++ b/tests/workers/screenshot_worker_tests.rb @@ -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'))