From 7458ca8ebb093af93c01cb61dabca15fd0c995cb Mon Sep 17 00:00:00 2001 From: Jan Provaznik Date: Thu, 21 Jun 2018 08:24:03 +0200 Subject: [backend] Addressed review comments * Group filtering now includes also issues/MRs from subgroups/subprojects * fixed due_date * Also DRYed todo controller specs --- lib/api/entities.rb | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'lib/api') diff --git a/lib/api/entities.rb b/lib/api/entities.rb index 375114f524b..06671c84fab 100644 --- a/lib/api/entities.rb +++ b/lib/api/entities.rb @@ -769,14 +769,14 @@ module API class Todo < Grape::Entity expose :id - expose :project, using: Entities::ProjectIdentity, if: -> (todo, _) { todo.project } - expose :group, using: 'API::Entities::NamespaceBasic', if: -> (todo, _) { todo.group } + expose :project, using: Entities::ProjectIdentity, if: -> (todo, _) { todo.project_id } + expose :group, using: 'API::Entities::NamespaceBasic', if: -> (todo, _) { todo.group_id } expose :author, using: Entities::UserBasic expose :action_name expose :target_type expose :target do |todo, options| - Entities.const_get(todo.target_type).represent(todo.target, options) + todo_target_class(todo.target_type).represent(todo.target, options) end expose :target_url do |todo, options| @@ -792,6 +792,10 @@ module API expose :body expose :state expose :created_at + + def todo_target_class(target_type) + ::API::Entities.const_get(target_type) + end end class NamespaceBasic < Grape::Entity -- cgit v1.2.1