summaryrefslogtreecommitdiff
path: root/app/models/todo.rb
diff options
context:
space:
mode:
Diffstat (limited to 'app/models/todo.rb')
-rw-r--r--app/models/todo.rb19
1 files changed, 19 insertions, 0 deletions
diff --git a/app/models/todo.rb b/app/models/todo.rb
index 2792fa9b9a8..ac3fdbc7f3b 100644
--- a/app/models/todo.rb
+++ b/app/models/todo.rb
@@ -4,6 +4,13 @@ class Todo < ActiveRecord::Base
BUILD_FAILED = 3
MARKED = 4
+ ACTION_NAMES = {
+ ASSIGNED => :assigned,
+ MENTIONED => :mentioned,
+ BUILD_FAILED => :build_failed,
+ MARKED => :marked
+ }
+
belongs_to :author, class_name: "User"
belongs_to :note
belongs_to :project
@@ -30,10 +37,16 @@ class Todo < ActiveRecord::Base
state :done
end
+ after_save :keep_around_commit
+
def build_failed?
action == BUILD_FAILED
end
+ def action_name
+ ACTION_NAMES[action]
+ end
+
def body
if note.present?
note.note
@@ -62,4 +75,10 @@ class Todo < ActiveRecord::Base
target.to_reference
end
end
+
+ private
+
+ def keep_around_commit
+ project.repository.keep_around(self.commit_id)
+ end
end