summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--app/controllers/projects/badges_controller.rb3
-rw-r--r--app/views/projects/badges/badge.svg.erb2
-rw-r--r--features/steps/project/badges/build.rb2
-rw-r--r--lib/gitlab/badge/build.rb4
4 files changed, 8 insertions, 3 deletions
diff --git a/app/controllers/projects/badges_controller.rb b/app/controllers/projects/badges_controller.rb
index a9f482c8787..d0f5071d2cc 100644
--- a/app/controllers/projects/badges_controller.rb
+++ b/app/controllers/projects/badges_controller.rb
@@ -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
diff --git a/app/views/projects/badges/badge.svg.erb b/app/views/projects/badges/badge.svg.erb
index 5a71419d3af..de461997c46 100644
--- a/app/views/projects/badges/badge.svg.erb
+++ b/app/views/projects/badges/badge.svg.erb
@@ -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>
diff --git a/features/steps/project/badges/build.rb b/features/steps/project/badges/build.rb
index 66a48a176e5..96c59322f9b 100644
--- a/features/steps/project/badges/build.rb
+++ b/features/steps/project/badges/build.rb
@@ -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
diff --git a/lib/gitlab/badge/build.rb b/lib/gitlab/badge/build.rb
index 7bc6f285ce1..c94ef3e9678 100644
--- a/lib/gitlab/badge/build.rb
+++ b/lib/gitlab/badge/build.rb
@@ -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