diff options
author | Robert Schilling <rschilling@student.tugraz.at> | 2016-06-15 13:20:30 +0200 |
---|---|---|
committer | Robert Schilling <rschilling@student.tugraz.at> | 2016-07-01 10:49:34 +0200 |
commit | 631765748ebff2307a078dc6d50ef8367f3c5ff0 (patch) | |
tree | 4a6a9cf285de1bbd86b43111addac1d82a1fdc20 | |
parent | 69397d559f837cb55fd50d5d0459523854dcec06 (diff) | |
download | gitlab-ce-631765748ebff2307a078dc6d50ef8367f3c5ff0.tar.gz |
Expose action_name
-rw-r--r-- | app/models/todo.rb | 11 | ||||
-rw-r--r-- | lib/api/entities.rb | 2 | ||||
-rw-r--r-- | spec/requests/api/todos_spec.rb | 1 |
3 files changed, 13 insertions, 1 deletions
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 |