diff options
author | Douwe Maan <douwe@selenight.nl> | 2016-06-01 13:39:56 +0200 |
---|---|---|
committer | Douwe Maan <douwe@selenight.nl> | 2016-06-01 13:39:56 +0200 |
commit | d1c537ad32cdb4993d09318de3a6debf1d37261d (patch) | |
tree | 96c4e35cb35bf24426c43f24b34ff141d1dd86d9 /app | |
parent | 9d88a3a1ddf77a2512864df4785bce8f9f566ee1 (diff) | |
parent | aeb5262d427e1b61ded71cc4a20e8e2a7a0089ef (diff) | |
download | gitlab-ce-d1c537ad32cdb4993d09318de3a6debf1d37261d.tar.gz |
Merge branch 'long.polyglot/gitlab-ce-issue_17479_todos_not_remove_when_leave_project'
Diffstat (limited to 'app')
-rw-r--r-- | app/models/members/project_member.rb | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/app/models/members/project_member.rb b/app/models/members/project_member.rb index 8dae3bb2ef2..46955b430f3 100644 --- a/app/models/members/project_member.rb +++ b/app/models/members/project_member.rb @@ -5,7 +5,6 @@ class ProjectMember < Member belongs_to :project, class_name: 'Project', foreign_key: 'source_id' - # Make sure project member points only to project as it source default_value_for :source_type, SOURCE_TYPE validates_format_of :source_type, with: /\AProject\z/ @@ -15,6 +14,8 @@ class ProjectMember < Member scope :in_projects, ->(projects) { where(source_id: projects.pluck(:id)) } scope :with_user, ->(user) { where(user_id: user.id) } + before_destroy :delete_member_todos + class << self # Add users to project teams with passed access option @@ -102,6 +103,10 @@ class ProjectMember < Member private + def delete_member_todos + user.todos.where(project_id: source_id).destroy_all if user + end + def send_invite notification_service.invite_project_member(self, @raw_invite_token) |