diff options
author | Douwe Maan <douwe@selenight.nl> | 2016-06-18 01:42:36 +0300 |
---|---|---|
committer | Douwe Maan <douwe@selenight.nl> | 2016-06-18 01:42:36 +0300 |
commit | b218e82b5c8dca6bdf84e160f47145fdc458a40c (patch) | |
tree | 7ac79863e34ceeefe08f14babf6ca37bbde4455b /app/controllers/projects/todos_controller.rb | |
parent | 5ef749b7ad940945340a726777a83f9098ed8791 (diff) | |
parent | 914f97310815365f083a38b02d8dbf6c99b63b5f (diff) |
Merge branch 'issuable-todo-improvements'
# Conflicts:
# app/controllers/projects/todos_controller.rb
Diffstat (limited to 'app/controllers/projects/todos_controller.rb')
-rw-r--r-- | app/controllers/projects/todos_controller.rb | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/app/controllers/projects/todos_controller.rb b/app/controllers/projects/todos_controller.rb index 648d42c56c5..23868d986e9 100644 --- a/app/controllers/projects/todos_controller.rb +++ b/app/controllers/projects/todos_controller.rb @@ -1,18 +1,12 @@ class Projects::TodosController < Projects::ApplicationController - def create - todos = TodoService.new.mark_todo(issuable, current_user) - - render json: { - todo: todos, - count: current_user.todos_pending_count, - } - end + before_action :authenticate_user!, only: [:create] - def update - current_user.todos.find_by_id(params[:id]).update(state: :done) + def create + todo = TodoService.new.mark_todo(issuable, current_user) render json: { count: current_user.todos_pending_count, + delete_path: dashboard_todo_path(todo) } end @@ -22,7 +16,13 @@ class Projects::TodosController < Projects::ApplicationController @issuable ||= begin case params[:issuable_type] when "issue" - @project.issues.find(params[:issuable_id]) + issue = @project.issues.find(params[:issuable_id]) + + if can?(current_user, :read_issue, issue) + issue + else + render_404 + end when "merge_request" @project.merge_requests.find(params[:issuable_id]) end |