diff options
author | Felipe Artur <felipefac@gmail.com> | 2019-05-21 22:20:27 +0300 |
---|---|---|
committer | Felipe Artur <felipefac@gmail.com> | 2019-06-05 16:51:52 +0300 |
commit | be339468192c656bf9de0bb77d7e487f338902bf (patch) | |
tree | 81bb43511ab8d8cb7deedf844c8526f8d7b05051 /app/models/todo.rb | |
parent | c9da437599027e9f2ef9f78a5167237f4b2a54dd (diff) |
Delete unauthorized Todos when project is private
Delete Todos for guest users when project visibility
level is updated to private.
Diffstat (limited to 'app/models/todo.rb')
-rw-r--r-- | app/models/todo.rb | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/app/models/todo.rb b/app/models/todo.rb index 5dcc3e9945a..f1fc5e599eb 100644 --- a/app/models/todo.rb +++ b/app/models/todo.rb @@ -38,7 +38,9 @@ class Todo < ApplicationRecord self end }, polymorphic: true, touch: true # rubocop:disable Cop/PolymorphicAssociations + belongs_to :user + belongs_to :issue, -> { where("target_type = 'Issue'") }, foreign_key: :target_id delegate :name, :email, to: :author, prefix: true, allow_nil: true @@ -59,6 +61,7 @@ class Todo < ApplicationRecord scope :for_target, -> (id) { where(target_id: id) } scope :for_commit, -> (id) { where(commit_id: id) } scope :with_api_entity_associations, -> { preload(:target, :author, :note, group: :route, project: [:route, { namespace: :route }]) } + scope :joins_issue_and_assignees, -> { left_joins(issue: :assignees) } state_machine :state, initial: :pending do event :done do |