summaryrefslogtreecommitdiff
path: root/app/controllers/projects/badges_controller.rb
blob: 6c25cd83a24353c6c5321248e997691136c721f9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
class Projects::BadgesController < Projects::ApplicationController
  layout 'project_settings'
  before_action :authorize_admin_project!, only: [:index]
  before_action :no_cache_headers, except: [:index]

  def build
    build_status = Gitlab::Badge::Build::Status
      .new(project, params[:ref])

    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)
    respond_to do |format|
      format.html { render_404 }
      format.svg do
        render 'badge', locals: { badge: badge.template }
      end
    end
  end
end