BigW Consortium Gitlab

badges_controller.rb 699 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
  def build
7 8
    build_status = Gitlab::Badge::Build::Status
      .new(project, params[:ref])
9

10 11 12 13 14 15 16 17 18 19 20 21 22
    render_badge build_status
  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