diff --git a/app/controllers/projects/commit_controller.rb b/app/controllers/projects/commit_controller.rb
index 637a911177c13cfc0fe75e4b74dc6dd43c379171..36fef1740e2b3be3ceef180264180119d3d4037a 100644
--- a/app/controllers/projects/commit_controller.rb
+++ b/app/controllers/projects/commit_controller.rb
@@ -57,9 +57,8 @@ class Projects::CommitController < Projects::ApplicationController
     render layout: false
   end
 
-  def status
-    status_sha = ci_commit.sha if ci_commit
-    image = Ci::ImageForBuildService.new.execute(@project, sha: status_sha)
+  def badge
+    image = Ci::ImageForBuildService.new.execute(@project, ref: params[:id])
     send_file(image.path, filename: image.name, disposition: 'inline', type: 'image/svg+xml')
   end
 
diff --git a/app/services/ci/image_for_build_service.rb b/app/services/ci/image_for_build_service.rb
index f469b13e90277f0be45954ab9f40543e7e5f5ebc..005a5c4661ca0750e0c96c4b67cf253e94592d73 100644
--- a/app/services/ci/image_for_build_service.rb
+++ b/app/services/ci/image_for_build_service.rb
@@ -1,28 +1,23 @@
 module Ci
   class ImageForBuildService
-    def execute(project, params)
-      sha = params[:sha]
-      sha ||=
-        if params[:ref]
-          project.commit(params[:ref]).try(:sha)
-        end
+    def execute(project, opts)
+      sha = opts[:sha] || ref_sha(project, opts[:ref])
 
       commit = project.ci_commits.ordered.find_by(sha: sha)
       image_name = image_for_commit(commit)
 
       image_path = Rails.root.join('public/ci', image_name)
-
-      OpenStruct.new(
-        path: image_path,
-        name: image_name
-      )
+      OpenStruct.new(path: image_path, name: image_name)
     end
 
     private
 
+    def ref_sha(project, ref)
+      project.commit(ref).try(:sha) if ref
+    end
+
     def image_for_commit(commit)
       return 'build-unknown.svg' unless commit
-
       'build-' + commit.status + ".svg"
     end
   end
diff --git a/config/routes.rb b/config/routes.rb
index 30e42e197f4b252d6db2b68d5acd8f20953907a1..152a04061f2b9d31a12535b6421d5df1ac3fdaab 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -496,9 +496,9 @@ Rails.application.routes.draw do
 
           get(
             '/status/*id/badge',
-            to: 'commit#status',
+            to: 'commit#badge',
             constraints: { format: /png/ },
-            as: :commit_status
+            as: :commit_badge
           )
         end