diff options
author | Rémy Coutable <remy@rymai.me> | 2016-09-09 09:57:31 +0000 |
---|---|---|
committer | Rémy Coutable <remy@rymai.me> | 2016-09-09 09:57:31 +0000 |
commit | 12cc675ceb2c52b3f39260b807e48be91edb598c (patch) | |
tree | 7ad47dd5db0e64a9714a273edcede8ac33d359e5 /app | |
parent | cf76776d03885c02b58df07dbca42bc455f4a841 (diff) | |
parent | 28e6bb39de56376fc4672ffc41927d63ad2f2440 (diff) | |
download | gitlab-ce-12cc675ceb2c52b3f39260b807e48be91edb598c.tar.gz |
Merge branch '21714-refresh-the-todos-count-cache-after-issuable-delete' into 'master'
Refresh todos count cache when an Issue/MR is deleted
Fixes #21714
See merge request !6161
Diffstat (limited to 'app')
-rw-r--r-- | app/controllers/concerns/issuable_actions.rb | 2 | ||||
-rw-r--r-- | app/services/todo_service.rb | 20 |
2 files changed, 22 insertions, 0 deletions
diff --git a/app/controllers/concerns/issuable_actions.rb b/app/controllers/concerns/issuable_actions.rb index 77b4efffd7f..bb32bc502e6 100644 --- a/app/controllers/concerns/issuable_actions.rb +++ b/app/controllers/concerns/issuable_actions.rb @@ -8,6 +8,8 @@ module IssuableActions def destroy issuable.destroy + destroy_method = "destroy_#{issuable.class.name.underscore}".to_sym + TodoService.new.public_send(destroy_method, issuable, current_user) name = issuable.class.name.titleize.downcase flash[:notice] = "The #{name} was successfully deleted." diff --git a/app/services/todo_service.rb b/app/services/todo_service.rb index 2aab8c736d6..776530ac0a5 100644 --- a/app/services/todo_service.rb +++ b/app/services/todo_service.rb @@ -31,6 +31,14 @@ class TodoService mark_pending_todos_as_done(issue, current_user) end + # When we destroy an issue we should: + # + # * refresh the todos count cache for the current user + # + def destroy_issue(issue, current_user) + destroy_issuable(issue, current_user) + end + # When we reassign an issue we should: # # * create a pending todo for new assignee if issue is assigned @@ -64,6 +72,14 @@ class TodoService mark_pending_todos_as_done(merge_request, current_user) end + # When we destroy a merge request we should: + # + # * refresh the todos count cache for the current user + # + def destroy_merge_request(merge_request, current_user) + destroy_issuable(merge_request, current_user) + end + # When we reassign a merge request we should: # # * creates a pending todo for new assignee if merge request is assigned @@ -187,6 +203,10 @@ class TodoService create_mention_todos(issuable.project, issuable, author) end + def destroy_issuable(issuable, user) + user.update_todos_count_cache + end + def toggling_tasks?(issuable) issuable.previous_changes.include?('description') && issuable.tasks? && issuable.updated_tasks.any? |