Skip to content

Commit

Permalink
Expose author username in project events API
Browse files Browse the repository at this point in the history
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
  • Loading branch information
dzaporozhets committed Oct 31, 2014
1 parent 80059cb commit ef9f867
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 0 deletions.
3 changes: 3 additions & 0 deletions doc/api/projects.md
Expand Up @@ -186,6 +186,7 @@ Parameters:
"target_id": 830,
"target_type": "Issue",
"author_id": 1,
"author_username": "john",
"data": null,
"target_title": "Public project search field"
},
Expand All @@ -196,6 +197,7 @@ Parameters:
"target_id": null,
"target_type": null,
"author_id": 1,
"author_username": "john",
"data": {
"before": "50d4420237a9de7be1304607147aec22e4a14af7",
"after": "c5feabde2d8cd023215af4d2ceeb7a64839fc428",
Expand Down Expand Up @@ -231,6 +233,7 @@ Parameters:
"target_id": 840,
"target_type": "Issue",
"author_id": 1,
"author_username": "john",
"data": null,
"target_title": "Finish & merge Code search PR"
}
Expand Down
6 changes: 6 additions & 0 deletions lib/api/entities.rb
Expand Up @@ -183,6 +183,12 @@ class Event < Grape::Entity
expose :target_id, :target_type, :author_id
expose :data, :target_title
expose :created_at

expose :author_username do |event, options|
if event.author
event.author.username
end
end
end

class Namespace < Grape::Entity
Expand Down
1 change: 1 addition & 0 deletions spec/requests/api/projects_spec.rb
Expand Up @@ -339,6 +339,7 @@

json_event['action_name'].should == 'joined'
json_event['project_id'].to_i.should == project.id
json_event['author_username'].should == user.username
end

it "should return a 404 error if not found" do
Expand Down

0 comments on commit ef9f867

Please sign in to comment.