badges_controller.rb 711 Bytes
Newer Older
1
class Projects::BadgesController < Projects::ApplicationController
2 3
  layout 'project_settings'
  before_action :authorize_admin_project!, only: [:index]
4 5
  before_action :no_cache_headers, except: [:index]

6 7
  def pipeline
    pipeline_status = Gitlab::Badge::Pipeline::Status
8
      .new(project, params[:ref])
9

10
    render_badge pipeline_status
11 12 13 14 15 16 17 18 19 20 21 22
  end

  def coverage
    coverage_report = Gitlab::Badge::Coverage::Report
      .new(project, params[:ref], params[:job])

    render_badge coverage_report
  end

  private

  def render_badge(badge)
23 24 25
    respond_to do |format|
      format.html { render_404 }
      format.svg do
26
        render 'badge', locals: { badge: badge.template }
27 28 29 30
      end
    end
  end
end