summaryrefslogtreecommitdiff
path: root/app/models/deployment.rb
diff options
context:
space:
mode:
Diffstat (limited to 'app/models/deployment.rb')
-rw-r--r--app/models/deployment.rb25
1 files changed, 25 insertions, 0 deletions
diff --git a/app/models/deployment.rb b/app/models/deployment.rb
new file mode 100644
index 00000000000..7cdfc740441
--- /dev/null
+++ b/app/models/deployment.rb
@@ -0,0 +1,25 @@
+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
+
+ 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