summaryrefslogtreecommitdiff
path: root/app/controllers/commits_controller.rb
blob: e541ac07a7c772b4d2918156a8fb225f21a5be09 (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
class CommitsController < ApplicationController
  before_filter :authenticate_user!, except: [:status]
  before_filter :project
  before_filter :commit
  before_filter :authorize_access_project!, except: [:status]

  def show
    @builds = @commit.builds
  end

  def status
    render json: @commit.to_json(only: [:id, :sha], methods: [:status, :coverage])
  end

  private

  def project
    @project ||= Project.find(params[:project_id])
  end

  def commit
    @commit ||= Project.find(params[:project_id]).commits.find_by_sha_and_ref!(params[:id], params[:ref_id])
  end
end