diff options
author | Robert Speicher <robert@gitlab.com> | 2016-06-17 19:47:03 +0000 |
---|---|---|
committer | Robert Speicher <robert@gitlab.com> | 2016-06-17 19:47:03 +0000 |
commit | d97b3d140712c1d8ab5f00681f09b040ed31b156 (patch) | |
tree | 17af2b00658316410eca8ffd7caee2ac484efa88 /app/controllers | |
parent | d9d149244a050f32dd00a9a1898eb5c309eb50eb (diff) | |
parent | 16387947341ccf49eeec366725fadf901a20b10e (diff) | |
download | gitlab-ce-d97b3d140712c1d8ab5f00681f09b040ed31b156.tar.gz |
Merge branch 'fix-todos-counters' into 'master'
Ensure Todos counters doesn't count Todos for projects pending delete
Use `TodosFinder` instead of `current_user.todos` to filter projects
pending delete on Todos counters helpers.
Counters should not reflect the number of Todos displayed on the tabs.
Fixes #18633
See merge request !4663
Diffstat (limited to 'app/controllers')
-rw-r--r-- | app/controllers/dashboard/todos_controller.rb | 21 |
1 files changed, 8 insertions, 13 deletions
diff --git a/app/controllers/dashboard/todos_controller.rb b/app/controllers/dashboard/todos_controller.rb index 7842fb9ce63..3a2db3e6eeb 100644 --- a/app/controllers/dashboard/todos_controller.rb +++ b/app/controllers/dashboard/todos_controller.rb @@ -1,5 +1,7 @@ class Dashboard::TodosController < Dashboard::ApplicationController - before_action :find_todos, only: [:index, :destroy, :destroy_all] + include TodosHelper + + before_action :find_todos, only: [:index, :destroy_all] def index @todos = @todos.page(params[:page]) @@ -8,14 +10,10 @@ class Dashboard::TodosController < Dashboard::ApplicationController def destroy TodoService.new.mark_todos_as_done([todo], current_user) - todo_notice = 'Todo was successfully marked as done.' - respond_to do |format| - format.html { redirect_to dashboard_todos_path, notice: todo_notice } + format.html { redirect_to dashboard_todos_path, notice: 'Todo was successfully marked as done.' } format.js { head :ok } - format.json do - render json: { count: @todos.size, done_count: current_user.todos_done_count } - end + format.json { render json: { count: todos_pending_count, done_count: todos_done_count } } end end @@ -25,20 +23,17 @@ class Dashboard::TodosController < Dashboard::ApplicationController respond_to do |format| format.html { redirect_to dashboard_todos_path, notice: 'All todos were marked as done.' } format.js { head :ok } - format.json do - find_todos - render json: { count: @todos.size, done_count: current_user.todos_done_count } - end + format.json { render json: { count: todos_pending_count, done_count: todos_done_count } } end end private def todo - @todo ||= current_user.todos.find(params[:id]) + @todo ||= find_todos.find(params[:id]) end def find_todos - @todos = TodosFinder.new(current_user, params).execute + @todos ||= TodosFinder.new(current_user, params).execute end end |