summaryrefslogtreecommitdiff
path: root/app/models/todo.rb
diff options
context:
space:
mode:
authorJarka Kadlecová <jarka@gitlab.com>2018-07-16 15:35:19 +0200
committerJarka Kadlecová <jarka@gitlab.com>2018-08-02 10:42:45 +0200
commit15179878d57addb010b5afeadd4bde8b62ef3acb (patch)
treeaad121955d9ab691584613e3aea20a1b9c5eeaea /app/models/todo.rb
parent0233fffe283857d9934460625f9c17fcd278536b (diff)
downloadgitlab-ce-15179878d57addb010b5afeadd4bde8b62ef3acb.tar.gz
Revert "Revert "Merge branch 'ee-5481-epic-todos' into 'master'""
This reverts commit 8717c7dad9b5a8fa21ec9a652c54718a6b4c2175.
Diffstat (limited to 'app/models/todo.rb')
-rw-r--r--app/models/todo.rb11
1 files changed, 9 insertions, 2 deletions
diff --git a/app/models/todo.rb b/app/models/todo.rb
index a2ab405fdbe..942cbb754e3 100644
--- a/app/models/todo.rb
+++ b/app/models/todo.rb
@@ -22,15 +22,18 @@ class Todo < ActiveRecord::Base
belongs_to :author, class_name: "User"
belongs_to :note
belongs_to :project
+ belongs_to :group
belongs_to :target, polymorphic: true, touch: true # rubocop:disable Cop/PolymorphicAssociations
belongs_to :user
delegate :name, :email, to: :author, prefix: true, allow_nil: true
- validates :action, :project, :target_type, :user, presence: true
+ validates :action, :target_type, :user, presence: true
validates :author, presence: true
validates :target_id, presence: true, unless: :for_commit?
validates :commit_id, presence: true, if: :for_commit?
+ validates :project, presence: true, unless: :group_id
+ validates :group, presence: true, unless: :project_id
scope :pending, -> { with_state(:pending) }
scope :done, -> { with_state(:done) }
@@ -44,7 +47,7 @@ class Todo < ActiveRecord::Base
state :done
end
- after_save :keep_around_commit
+ after_save :keep_around_commit, if: :commit_id
class << self
# Priority sorting isn't displayed in the dropdown, because we don't show
@@ -79,6 +82,10 @@ class Todo < ActiveRecord::Base
end
end
+ def parent
+ project
+ end
+
def unmergeable?
action == UNMERGEABLE
end