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

28 lines
498 B
Ruby
Raw Normal View History

2016-06-10 21:36:54 +00:00
class Deployment < ActiveRecord::Base
include InternalId
belongs_to :project
belongs_to :environment
belongs_to :user
belongs_to :deployable, polymorphic: true
validates_presence_of :sha
validates_presence_of :ref
2016-06-14 11:51:12 +00:00
validates_associated :project
validates_associated :environment
2016-06-10 21:36:54 +00:00
delegate :name, to: :environment, prefix: true
def commit
project.commit(sha)
end
def commit_title
commit.try(:title)
end
def short_sha
Commit::truncate_sha(sha)
end
end