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

Rename CiStatus to Statusable

parent 065e0c0f
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
module Ci module Ci
class Commit < ActiveRecord::Base class Commit < ActiveRecord::Base
extend Ci::Model extend Ci::Model
include CiStatus include Statuseable
belongs_to :project, class_name: '::Project', foreign_key: :gl_project_id belongs_to :project, class_name: '::Project', foreign_key: :gl_project_id
has_many :statuses, class_name: 'CommitStatus' has_many :statuses, class_name: 'CommitStatus'
......
...@@ -33,7 +33,7 @@ ...@@ -33,7 +33,7 @@
# #
class CommitStatus < ActiveRecord::Base class CommitStatus < ActiveRecord::Base
include CiStatus include Statuseable
self.table_name = 'ci_builds' self.table_name = 'ci_builds'
...@@ -81,7 +81,11 @@ class CommitStatus < ActiveRecord::Base ...@@ -81,7 +81,11 @@ class CommitStatus < ActiveRecord::Base
end end
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 def self.stages
order_by = 'max(stage_idx)' order_by = 'max(stage_idx)'
......
module CiStatus module Statuseable
extend ActiveSupport::Concern extend ActiveSupport::Concern
AVAILABLE_STATUSES = %w(pending running success failed canceled skipped) AVAILABLE_STATUSES = %w(pending running success failed canceled skipped)
...@@ -41,7 +41,7 @@ module CiStatus ...@@ -41,7 +41,7 @@ module CiStatus
end end
def finished_at def finished_at
all.minimum(:finished_at) all.maximum(:finished_at)
end end
end end
......
...@@ -958,7 +958,7 @@ class Project < ActiveRecord::Base ...@@ -958,7 +958,7 @@ class Project < ActiveRecord::Base
end end
def ci_commit(sha, ref) 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 end
def ensure_ci_commit(sha, ref) def ensure_ci_commit(sha, ref)
......
.gray-content-block.middle-block .gray-content-block.middle-block
.pull-right .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?) - 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 = 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 ...@@ -163,4 +163,12 @@ eos
it { expect(commit.reverts_commit?(another_commit)).to be_truthy } it { expect(commit.reverts_commit?(another_commit)).to be_truthy }
end end
end end
describe '#ci_commits' do
# TODO: kamil
end
describe '#status' do
# TODO: kamil
end
end end
require 'spec_helper' require 'spec_helper'
describe CiStatus do describe Statuseable do
before do before do
@object = Object.new @object = Object.new
@object.extend(CiStatus::ClassMethods) @object.extend(Statuseable::ClassMethods)
end end
describe '.status' do 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