Skip to content

Commit

Permalink
Fix up
Browse files Browse the repository at this point in the history
  • Loading branch information
paveg committed Jul 31, 2018
1 parent 549a1f9 commit 5797fd0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
8 changes: 6 additions & 2 deletions lib/lgtm/plugin.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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 "<h1 align="center">LGTM</h1>" when Service Temporarily Unavailable; Over Quota.
lgtm_post_url = lgtm_post_req['location']

lgtm_post_response = process_request(lgtm_post_url) do |req|
Expand Down Expand Up @@ -70,7 +70,11 @@ def process_request(url)
end

def markdown_template(image_url)
"<p align='center'><img src='#{(image_url || '#')}' alt='LGTM' /></p>"
if image_url.nil?
"<h1 align='center'>LGTM</h1>"
else
"<p align='center'><img src='#{image_url}' alt='LGTM' /></p>"
end
end
end
end
6 changes: 3 additions & 3 deletions spec/lgtm_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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("<h1 align='center'>LGTM</h1>")
end

def mock(request_url: 'https://lgtm.in/p/sSuI4hm0q',
Expand Down

0 comments on commit 5797fd0

Please sign in to comment.