Commit 1b5e2303 authored by Grzegorz Bizon's avatar Grzegorz Bizon

Use new badge template to render build status badge

parent 503c44ee
......@@ -8,8 +8,9 @@ class Projects::BadgesController < Projects::ApplicationController
respond_to do |format|
format.html { render_404 }
format.svg do
send_data(badge.data, type: badge.type, disposition: 'inline')
render 'badge', locals: { badge: badge.template }
end
end
end
......
......@@ -10,7 +10,7 @@
<g mask="url(#a)">
<path fill="<%= badge.key_color%>" d="M0 0h <%= badge.key_width%>v 20H 0z"/>
<path fill="#4c1" d="M<%= badge.key_width%> 0h <%= badge.value_width %>v 20H <%= badge.key_width%>z"/>
<path fill="<%= badge.value_color %>" d="M<%= badge.key_width%> 0h <%= badge.value_width %>v 20H <%= badge.key_width%>z"/>
<path fill="url(#b)" d="M0 0h <%= badge.width %>v 20H 0z"/>
</g>
......
......@@ -26,7 +26,7 @@ class Spinach::Features::ProjectBadgesBuild < Spinach::FeatureSteps
def expect_badge(status)
svg = Nokogiri::XML.parse(page.body)
expect(page.response_headers).to include('Content-Type' => 'image/svg+xml')
expect(page.response_headers['Content-Type']).to include('image/svg+xml')
expect(svg.at(%Q{text:contains("#{status}")})).to be_truthy
end
end
......@@ -21,6 +21,10 @@ module Gitlab
Build::Metadata.new(@project, @ref)
end
def template
Build::Template.new(status)
end
def type
'image/svg+xml'
end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment