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 ...@@ -8,8 +8,9 @@ class Projects::BadgesController < Projects::ApplicationController
respond_to do |format| respond_to do |format|
format.html { render_404 } format.html { render_404 }
format.svg do format.svg do
send_data(badge.data, type: badge.type, disposition: 'inline') render 'badge', locals: { badge: badge.template }
end end
end end
end end
......
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
<g mask="url(#a)"> <g mask="url(#a)">
<path fill="<%= badge.key_color%>" d="M0 0h <%= badge.key_width%>v 20H 0z"/> <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"/> <path fill="url(#b)" d="M0 0h <%= badge.width %>v 20H 0z"/>
</g> </g>
......
...@@ -26,7 +26,7 @@ class Spinach::Features::ProjectBadgesBuild < Spinach::FeatureSteps ...@@ -26,7 +26,7 @@ class Spinach::Features::ProjectBadgesBuild < Spinach::FeatureSteps
def expect_badge(status) def expect_badge(status)
svg = Nokogiri::XML.parse(page.body) 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 expect(svg.at(%Q{text:contains("#{status}")})).to be_truthy
end end
end end
...@@ -21,6 +21,10 @@ module Gitlab ...@@ -21,6 +21,10 @@ module Gitlab
Build::Metadata.new(@project, @ref) Build::Metadata.new(@project, @ref)
end end
def template
Build::Template.new(status)
end
def type def type
'image/svg+xml' 'image/svg+xml'
end 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