From 631765748ebff2307a078dc6d50ef8367f3c5ff0 Mon Sep 17 00:00:00 2001 From: Robert Schilling Date: Wed, 15 Jun 2016 13:20:30 +0200 Subject: Expose action_name --- app/models/todo.rb | 11 +++++++++++ lib/api/entities.rb | 2 +- spec/requests/api/todos_spec.rb | 1 + 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/app/models/todo.rb b/app/models/todo.rb index 2792fa9b9a8..3ba67078d48 100644 --- a/app/models/todo.rb +++ b/app/models/todo.rb @@ -4,6 +4,13 @@ class Todo < ActiveRecord::Base BUILD_FAILED = 3 MARKED = 4 + ACTION_NAMES = { + ASSIGNED => :assigned, + MENTIONED => :mentioned, + BUILD_FAILED => :build_failed, + MARKED => :marked + } + belongs_to :author, class_name: "User" belongs_to :note belongs_to :project @@ -34,6 +41,10 @@ class Todo < ActiveRecord::Base action == BUILD_FAILED end + def action_name + ACTION_NAMES[action] + end + def body if note.present? note.note diff --git a/lib/api/entities.rb b/lib/api/entities.rb index 88f7fc7ff6c..67d2c396b32 100644 --- a/lib/api/entities.rb +++ b/lib/api/entities.rb @@ -276,7 +276,7 @@ module API expose :id expose :project, using: Entities::BasicProjectDetails expose :author, using: Entities::UserBasic - #expose :action_name + expose :action_name expose :target_id expose :target_type expose :target_reference do |todo, options| diff --git a/spec/requests/api/todos_spec.rb b/spec/requests/api/todos_spec.rb index 1960db59c99..8d54b4fd3d8 100644 --- a/spec/requests/api/todos_spec.rb +++ b/spec/requests/api/todos_spec.rb @@ -44,6 +44,7 @@ describe API::Todos, api: true do expect(json_response[0]['target_url']).to be_present expect(json_response[0]['body']).to be_present expect(json_response[0]['state']).to eq('pending') + expect(json_response[0]['action_name']).to eq('assigned') expect(json_response[0]['created_at']).to be_present end -- cgit v1.2.1