From 39e6f504fcb8c6cab511a50cdefd76e821bfec17 Mon Sep 17 00:00:00 2001 From: Robert Schilling <rschilling@student.tugraz.at> Date: Sat, 21 May 2016 19:01:11 +0200 Subject: [PATCH] Move to helper, no instance variables --- app/models/todo.rb | 7 ------- app/views/dashboard/todos/_todo.html.haml | 2 +- lib/api/todos.rb | 18 +++++++++--------- 3 files changed, 10 insertions(+), 17 deletions(-) diff --git a/app/models/todo.rb b/app/models/todo.rb index 42faecdf7f2..2792fa9b9a8 100644 --- a/app/models/todo.rb +++ b/app/models/todo.rb @@ -34,13 +34,6 @@ class Todo < ActiveRecord::Base action == BUILD_FAILED end - def action_name - case action - when Todo::ASSIGNED then 'assigned you' - when Todo::MENTIONED then 'mentioned you on' - end - end - def body if note.present? note.note diff --git a/app/views/dashboard/todos/_todo.html.haml b/app/views/dashboard/todos/_todo.html.haml index 421885eef5b..98f302d2f93 100644 --- a/app/views/dashboard/todos/_todo.html.haml +++ b/app/views/dashboard/todos/_todo.html.haml @@ -11,7 +11,7 @@ - else (removed) %span.todo-label - = todo.action_name + = todo_action_name(todo) - if todo.target = todo_target_link(todo) - else diff --git a/lib/api/todos.rb b/lib/api/todos.rb index f45c0ae634a..db1f16cec59 100644 --- a/lib/api/todos.rb +++ b/lib/api/todos.rb @@ -14,11 +14,11 @@ module API # # Example Request: # GET /todos + # get do - @todos = find_todos - @todos = paginate @todos + todos = find_todos - present @todos, with: Entities::Todo + present paginate(todos), with: Entities::Todo end # Mark todo as done @@ -31,10 +31,10 @@ module API # DELETE /todos/:id # delete ':id' do - @todo = current_user.todos.find(params[:id]) - @todo.done + todo = current_user.todos.find(params[:id]) + todo.done - present @todo, with: Entities::Todo + present todo, with: Entities::Todo end # Mark all todos as done @@ -44,10 +44,10 @@ module API # DELETE /todos # delete do - @todos = find_todos - @todos.each(&:done) + todos = find_todos + todos.each(&:done) - present @todos, with: Entities::Todo + present paginate(todos), with: Entities::Todo end end end -- GitLab