gitlab-org--gitlab-foss/app/models/deployment.rb

30 lines
528 B
Ruby
Raw Normal View History

2016-06-10 17:36:54 -04:00
class Deployment < ActiveRecord::Base
include InternalId
belongs_to :project, validate: true
belongs_to :environment, validate: true
2016-06-10 17:36:54 -04:00
belongs_to :user
belongs_to :deployable, polymorphic: true
2016-06-14 12:34:48 -04:00
validates :sha, presence: true
validates :ref, presence: true
2016-06-10 17:36:54 -04:00
delegate :name, to: :environment, prefix: true
def commit
project.commit(sha)
end
def commit_title
commit.try(:title)
end
def short_sha
2016-06-14 12:34:48 -04:00
Commit.truncate_sha(sha)
2016-06-10 17:36:54 -04:00
end
2016-06-14 08:47:00 -04:00
def last?
self == environment.last_deployment
end
2016-06-10 17:36:54 -04:00
end