diff --git a/lib/lgtm/plugin.rb b/lib/lgtm/plugin.rb index 4246876..875b60d 100644 --- a/lib/lgtm/plugin.rb +++ b/lib/lgtm/plugin.rb @@ -41,7 +41,7 @@ def check_lgtm(image_url: nil, https_image_only: false) def fetch_image_url(https_image_only: false) lgtm_post_req = process_request(RANDOM_LGTM_POST_URL) - return if lgtm_post_req.code == '503' # returns "img tag src='#'" when Service Temporarily Unavailable; Over Quota. + return if lgtm_post_req.code == '503' # returns "

LGTM

" when Service Temporarily Unavailable; Over Quota. lgtm_post_url = lgtm_post_req['location'] lgtm_post_response = process_request(lgtm_post_url) do |req| @@ -70,7 +70,11 @@ def process_request(url) end def markdown_template(image_url) - "

LGTM

" + if image_url.nil? + "

LGTM

" + else + "

LGTM

" + end end end end diff --git a/spec/lgtm_spec.rb b/spec/lgtm_spec.rb index 0d472bf..678625b 100644 --- a/spec/lgtm_spec.rb +++ b/spec/lgtm_spec.rb @@ -24,11 +24,11 @@ module Danger @lgtm.check_lgtm expect(@dangerfile.status_report[:markdowns].length).to eq(1) end - it 'lgtm with default url is OverQuota' do allow(Net::HTTP).to receive(:start).and_return(mock(code: '503')) - - expect(@dangerfile.status_report[:markdowns]).to be_empty + @lgtm.check_lgtm + expect(@dangerfile.status_report[:markdowns][0].message) + .to eq("

LGTM

") end def mock(request_url: 'https://lgtm.in/p/sSuI4hm0q',