Expose action_name

This commit is contained in:
Robert Schilling 2016-06-15 13:20:30 +02:00
parent 69397d559f
commit 631765748e
3 changed files with 13 additions and 1 deletions

View file

@ -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

View file

@ -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|

View file

@ -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