summaryrefslogtreecommitdiff
path: root/app/models/deployment.rb
diff options
context:
space:
mode:
authorJames Lopez <james@jameslopez.es>2016-06-16 14:07:49 +0200
committerJames Lopez <james@jameslopez.es>2016-06-16 14:07:49 +0200
commit2a747d386dbdc05453fce6b8be3f483e8cd9e796 (patch)
tree5530f2fb8856c4e29a33afb128843108e2bb5834 /app/models/deployment.rb
parent862b359b9a3f271b23f393932fb0e85d65c56c6b (diff)
parent778d72664f386dfee45dab171f137395739958f6 (diff)
downloadgitlab-ce-2a747d386dbdc05453fce6b8be3f483e8cd9e796.tar.gz
fixed merge conflicts
Diffstat (limited to 'app/models/deployment.rb')
-rw-r--r--app/models/deployment.rb29
1 files changed, 29 insertions, 0 deletions
diff --git a/app/models/deployment.rb b/app/models/deployment.rb
new file mode 100644
index 00000000000..e498ca96e3c
--- /dev/null
+++ b/app/models/deployment.rb
@@ -0,0 +1,29 @@
+class Deployment < ActiveRecord::Base
+ include InternalId
+
+ belongs_to :project, required: true, validate: true
+ belongs_to :environment, required: true, validate: true
+ belongs_to :user
+ belongs_to :deployable, polymorphic: true
+
+ validates :sha, presence: true
+ validates :ref, presence: true
+
+ 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
+
+ def last?
+ self == environment.last_deployment
+ end
+end