diff options
author | Douglas Barbosa Alexandre <dbalexandre@gmail.com> | 2016-09-02 01:12:05 +0300 |
---|---|---|
committer | Douglas Barbosa Alexandre <dbalexandre@gmail.com> | 2016-09-08 21:50:07 +0300 |
commit | d86c6666623a90d46fa4cfe624c67e86c6ad235f (patch) | |
tree | c3290abd871d37f2addb0794b6f526fc31e9d66c /app | |
parent | 796bdf1dcb86b5e77fc054208afc632f75518605 (diff) |
Refresh todos count cache when an Issue/MR is deleted
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? |