diff options
author | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2014-10-31 13:08:45 +0300 |
---|---|---|
committer | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2014-10-31 13:08:45 +0300 |
commit | ef9f8677e65b4b791550daad4ebff8ae50c2f0d2 (patch) | |
tree | 0066343ba655353cca1f77d65c8d1065823638e6 | |
parent | 80059cb5231a557d0e86653a53e27ce19f62b488 (diff) |
Expose author username in project events API
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
-rw-r--r-- | doc/api/projects.md | 3 | ||||
-rw-r--r-- | lib/api/entities.rb | 6 | ||||
-rw-r--r-- | spec/requests/api/projects_spec.rb | 1 |
3 files changed, 10 insertions, 0 deletions
diff --git a/doc/api/projects.md b/doc/api/projects.md index dfe3502b6e4..0055e2e476f 100644 --- a/doc/api/projects.md +++ b/doc/api/projects.md @@ -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" }, @@ -196,6 +197,7 @@ Parameters: "target_id": null, "target_type": null, "author_id": 1, + "author_username": "john", "data": { "before": "50d4420237a9de7be1304607147aec22e4a14af7", "after": "c5feabde2d8cd023215af4d2ceeb7a64839fc428", @@ -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" } diff --git a/lib/api/entities.rb b/lib/api/entities.rb index d19caf5b23a..4e7b1c91c4e 100644 --- a/lib/api/entities.rb +++ b/lib/api/entities.rb @@ -183,6 +183,12 @@ module API 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 diff --git a/spec/requests/api/projects_spec.rb b/spec/requests/api/projects_spec.rb index ba7ec7b2be9..cb7a2705573 100644 --- a/spec/requests/api/projects_spec.rb +++ b/spec/requests/api/projects_spec.rb @@ -339,6 +339,7 @@ describe API::API, api: true do 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 |