summaryrefslogtreecommitdiff
path: root/app/models/deployment.rb
diff options
context:
space:
mode:
authorKamil Trzcinski <ayufan@ayufan.eu>2016-06-10 23:36:54 +0200
committerKamil Trzcinski <ayufan@ayufan.eu>2016-06-10 23:36:54 +0200
commit907c0e6796b69f9577c147dd489cf55748c749ac (patch)
treec4db6a3d3785fa845be98447eb4303b548ab7809 /app/models/deployment.rb
parentcf7da039bedcad5163ce9deedccc94206d4c485a (diff)
downloadgitlab-ce-907c0e6796b69f9577c147dd489cf55748c749ac.tar.gz
Added initial version of deployments
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