Commit 0b1655e7 authored by Kamil Trzcinski's avatar Kamil Trzcinski

Rename CiStatus to Statusable

parent 065e0c0f
......@@ -19,7 +19,7 @@
module Ci
class Commit < ActiveRecord::Base
extend Ci::Model
include CiStatus
include Statuseable
belongs_to :project, class_name: '::Project', foreign_key: :gl_project_id
has_many :statuses, class_name: 'CommitStatus'
......
......@@ -33,7 +33,7 @@
#
class CommitStatus < ActiveRecord::Base
include CiStatus
include Statuseable
self.table_name = 'ci_builds'
......@@ -81,7 +81,11 @@ class CommitStatus < ActiveRecord::Base
end
end
delegate :before_sha, :sha, :short_sha, to: :commit, prefix: false
delegate :sha, :short_sha, to: :commit
def before_sha
commit.before_sha || Gitlab::Git::BLANK_SHA
end
def self.stages
order_by = 'max(stage_idx)'
......
module CiStatus
module Statuseable
extend ActiveSupport::Concern
AVAILABLE_STATUSES = %w(pending running success failed canceled skipped)
......@@ -41,7 +41,7 @@ module CiStatus
end
def finished_at
all.minimum(:finished_at)
all.maximum(:finished_at)
end
end
......
......@@ -958,7 +958,7 @@ class Project < ActiveRecord::Base
end
def ci_commit(sha, ref)
ci_commits.find_by(sha: sha, ref: ref)
ci_commits.order(id: :desc).find_by(sha: sha, ref: ref)
end
def ensure_ci_commit(sha, ref)
......
.gray-content-block.middle-block
.pull-right
- if can?(current_user, :update_build, @project)
- if can?(current_user, :update_build, @ci_commit.project)
- if ci_commit.builds.latest.failed.any?(&:retryable?)
= link_to "Retry failed", retry_builds_namespace_project_commit_path(@project.namespace, @project, ci_commit.sha), class: 'btn btn-grouped btn-primary', method: :post
......
......@@ -163,4 +163,12 @@ eos
it { expect(commit.reverts_commit?(another_commit)).to be_truthy }
end
end
describe '#ci_commits' do
# TODO: kamil
end
describe '#status' do
# TODO: kamil
end
end
require 'spec_helper'
describe CiStatus do
describe Statuseable do
before do
@object = Object.new
@object.extend(CiStatus::ClassMethods)
@object.extend(Statuseable::ClassMethods)
end
describe '.status' do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment