Commit 63176574 authored by Robert Schilling's avatar Robert Schilling

Expose action_name

parent 69397d55
...@@ -4,6 +4,13 @@ class Todo < ActiveRecord::Base ...@@ -4,6 +4,13 @@ class Todo < ActiveRecord::Base
BUILD_FAILED = 3 BUILD_FAILED = 3
MARKED = 4 MARKED = 4
ACTION_NAMES = {
ASSIGNED => :assigned,
MENTIONED => :mentioned,
BUILD_FAILED => :build_failed,
MARKED => :marked
}
belongs_to :author, class_name: "User" belongs_to :author, class_name: "User"
belongs_to :note belongs_to :note
belongs_to :project belongs_to :project
...@@ -34,6 +41,10 @@ class Todo < ActiveRecord::Base ...@@ -34,6 +41,10 @@ class Todo < ActiveRecord::Base
action == BUILD_FAILED action == BUILD_FAILED
end end
def action_name
ACTION_NAMES[action]
end
def body def body
if note.present? if note.present?
note.note note.note
......
...@@ -276,7 +276,7 @@ module API ...@@ -276,7 +276,7 @@ module API
expose :id expose :id
expose :project, using: Entities::BasicProjectDetails expose :project, using: Entities::BasicProjectDetails
expose :author, using: Entities::UserBasic expose :author, using: Entities::UserBasic
#expose :action_name expose :action_name
expose :target_id expose :target_id
expose :target_type expose :target_type
expose :target_reference do |todo, options| expose :target_reference do |todo, options|
......
...@@ -44,6 +44,7 @@ describe API::Todos, api: true do ...@@ -44,6 +44,7 @@ describe API::Todos, api: true do
expect(json_response[0]['target_url']).to be_present expect(json_response[0]['target_url']).to be_present
expect(json_response[0]['body']).to be_present expect(json_response[0]['body']).to be_present
expect(json_response[0]['state']).to eq('pending') 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 expect(json_response[0]['created_at']).to be_present
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment