summaryrefslogtreecommitdiff
path: root/app/models
diff options
context:
space:
mode:
authorKamil Trzcinski <ayufan@ayufan.eu>2016-04-16 21:46:26 +0200
committerKamil Trzcinski <ayufan@ayufan.eu>2016-04-16 21:46:26 +0200
commit0b1655e7b2e2aa57cb7ea8401743d709bf246074 (patch)
tree0f2846f32aec86f3d44300649b0c77f179bec0c4 /app/models
parent065e0c0fe4e5e16b90c01736721e4c794b71dac9 (diff)
downloadgitlab-ce-0b1655e7b2e2aa57cb7ea8401743d709bf246074.tar.gz
Rename CiStatus to Statusable
Diffstat (limited to 'app/models')
-rw-r--r--app/models/ci/commit.rb2
-rw-r--r--app/models/commit_status.rb8
-rw-r--r--app/models/concerns/statuseable.rb (renamed from app/models/concerns/ci_status.rb)4
-rw-r--r--app/models/project.rb2
4 files changed, 10 insertions, 6 deletions
diff --git a/app/models/ci/commit.rb b/app/models/ci/commit.rb
index ae30407bcae..412ab44aaf6 100644
--- a/app/models/ci/commit.rb
+++ b/app/models/ci/commit.rb
@@ -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'
diff --git a/app/models/commit_status.rb b/app/models/commit_status.rb
index 66eb5dcecf9..06d296eef08 100644
--- a/app/models/commit_status.rb
+++ b/app/models/commit_status.rb
@@ -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)'
diff --git a/app/models/concerns/ci_status.rb b/app/models/concerns/statuseable.rb
index 8190b2a20c6..f34dca29120 100644
--- a/app/models/concerns/ci_status.rb
+++ b/app/models/concerns/statuseable.rb
@@ -1,4 +1,4 @@
-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
diff --git a/app/models/project.rb b/app/models/project.rb
index 95eb7c51b80..3a55e6c5dd6 100644
--- a/app/models/project.rb
+++ b/app/models/project.rb
@@ -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)