summaryrefslogtreecommitdiff
path: root/app/models/commit_status.rb
diff options
context:
space:
mode:
authorTed Hogan <ted.hogan17@gmail.com>2015-12-29 11:25:46 -0700
committerTed Hogan <ted.hogan17@gmail.com>2015-12-29 11:25:46 -0700
commit9fc6df512b53ff0e589bc6be7932da8ecfec4033 (patch)
tree6d356b79b323c2efb7c4d2c92aff2cdfd7c17358 /app/models/commit_status.rb
parent6e6a99061dbec4bb45a398a03e8a13a084e44035 (diff)
parenteeba266e3d45f2e82f84bd3aab85195c890efb89 (diff)
downloadgitlab-ce-9fc6df512b53ff0e589bc6be7932da8ecfec4033.tar.gz
Merge branch 'master' of gitlab.com:gitlab-org/gitlab-ce into wipMergeSpacing
Diffstat (limited to 'app/models/commit_status.rb')
-rw-r--r--app/models/commit_status.rb62
1 files changed, 31 insertions, 31 deletions
diff --git a/app/models/commit_status.rb b/app/models/commit_status.rb
index e70f4d37184..21c5c87bc3d 100644
--- a/app/models/commit_status.rb
+++ b/app/models/commit_status.rb
@@ -1,39 +1,36 @@
# == Schema Information
#
-# Table name: ci_builds
-#
-# id :integer not null, primary key
-# project_id :integer
-# status :string(255)
-# finished_at :datetime
-# trace :text
-# created_at :datetime
-# updated_at :datetime
-# started_at :datetime
-# runner_id :integer
-# coverage :float
-# commit_id :integer
-# commands :text
-# job_id :integer
-# name :string(255)
-# deploy :boolean default(FALSE)
-# options :text
-# allow_failure :boolean default(FALSE), not null
-# stage :string(255)
-# trigger_request_id :integer
-# stage_idx :integer
-# tag :boolean
-# ref :string(255)
-# user_id :integer
-# type :string(255)
-# target_url :string(255)
-# description :string(255)
-# artifacts_file :text
+# project_id integer
+# status string
+# finished_at datetime
+# trace text
+# created_at datetime
+# updated_at datetime
+# started_at datetime
+# runner_id integer
+# coverage float
+# commit_id integer
+# commands text
+# job_id integer
+# name string
+# deploy boolean default: false
+# options text
+# allow_failure boolean default: false, null: false
+# stage string
+# trigger_request_id integer
+# stage_idx integer
+# tag boolean
+# ref string
+# user_id integer
+# type string
+# target_url string
+# description string
#
class CommitStatus < ActiveRecord::Base
self.table_name = 'ci_builds'
+ belongs_to :project, class_name: '::Project', foreign_key: :gl_project_id
belongs_to :commit, class_name: 'Ci::Commit'
belongs_to :user
@@ -79,6 +76,10 @@ class CommitStatus < ActiveRecord::Base
build.update_attributes finished_at: Time.now
end
+ after_transition [:pending, :running] => :success do |build, transition|
+ MergeRequests::MergeWhenBuildSucceedsService.new(build.commit.project, nil).trigger(build)
+ end
+
state :pending, value: 'pending'
state :running, value: 'running'
state :failed, value: 'failed'
@@ -86,8 +87,7 @@ class CommitStatus < ActiveRecord::Base
state :canceled, value: 'canceled'
end
- delegate :sha, :short_sha, :gl_project,
- to: :commit, prefix: false
+ delegate :sha, :short_sha, to: :commit, prefix: false
# TODO: this should be removed with all references
def before_sha