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

  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