Commit 28b11963 authored by Grzegorz Bizon's avatar Grzegorz Bizon

Move builds badge implementation to new badges controller

parent ee1bee58
class Projects::BadgesController < Projects::ApplicationController
def build
respond_to do |format|
format.html { render_404 }
format.svg do
image = Ci::ImageForBuildService.new.execute(project, ref: params[:ref])
send_file(image.path, filename: image.name, disposition: 'inline', type: 'image/svg+xml')
end
end
end
end
...@@ -56,16 +56,6 @@ class Projects::BuildsController < Projects::ApplicationController ...@@ -56,16 +56,6 @@ class Projects::BuildsController < Projects::ApplicationController
render json: @build.to_json(only: [:status, :id, :sha, :coverage], methods: :sha) render json: @build.to_json(only: [:status, :id, :sha, :coverage], methods: :sha)
end end
def badge
respond_to do |format|
format.html { render_404 }
format.svg do
image = Ci::ImageForBuildService.new.execute(project, ref: params[:ref])
send_file(image.path, filename: image.name, disposition: 'inline', type: 'image/svg+xml')
end
end
end
private private
def build def build
......
...@@ -611,8 +611,6 @@ Rails.application.routes.draw do ...@@ -611,8 +611,6 @@ Rails.application.routes.draw do
resources :builds, only: [:index, :show], constraints: { id: /\d+/ } do resources :builds, only: [:index, :show], constraints: { id: /\d+/ } do
collection do collection do
post :cancel_all post :cancel_all
get :badge, path: 'status/*ref/badge',
constraints: { ref: Gitlab::Regex.git_reference_regex, format: /svg/ }
end end
member do member do
...@@ -699,6 +697,12 @@ Rails.application.routes.draw do ...@@ -699,6 +697,12 @@ Rails.application.routes.draw do
end end
resources :runner_projects, only: [:create, :destroy] resources :runner_projects, only: [:create, :destroy]
resources :badges, only: [], path: 'badges/*ref',
constraints: { ref: Gitlab::Regex.git_reference_regex } do
collection do
get :build, constraints: { format: /svg/ }
end
end
end end
end end
end end
......
...@@ -189,7 +189,7 @@ GitLab, such as **Commits** and **Merge Requests**. ...@@ -189,7 +189,7 @@ GitLab, such as **Commits** and **Merge Requests**.
You can access a builds badge image using following link: You can access a builds badge image using following link:
``` ```
http://example.gitlab.com/namespace/project/builds/status/branch/badge.svg http://example.gitlab.com/namespace/project/badges/branch/build.svg
``` ```
## Next steps ## Next steps
......
...@@ -5,7 +5,7 @@ class Spinach::Features::ProjectBuildsBadge < Spinach::FeatureSteps ...@@ -5,7 +5,7 @@ class Spinach::Features::ProjectBuildsBadge < Spinach::FeatureSteps
include RepoHelpers include RepoHelpers
step 'I display builds badge for a master branch' do step 'I display builds badge for a master branch' do
visit badge_namespace_project_builds_path(@project.namespace, @project, ref: :master, format: :svg) visit build_namespace_project_badges_path(@project.namespace, @project, ref: :master, format: :svg)
end end
step 'I should see a build success badge' do step 'I should see a build success badge' do
......
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