Include the username in user_create/destroy system hooks.

This commit is contained in:
Tommy Beadle 2016-01-07 12:54:35 -05:00
parent fc386b65d0
commit dada25d447
3 changed files with 6 additions and 3 deletions

View file

@ -47,7 +47,8 @@ class SystemHooksService
data.merge!({ data.merge!({
name: model.name, name: model.name,
email: model.email, email: model.email,
user_id: model.id user_id: model.id,
username: model.username
}) })
when ProjectMember when ProjectMember
data.merge!(project_member_data(model)) data.merge!(project_member_data(model))

View file

@ -129,6 +129,7 @@ X-Gitlab-Event: System Hook
"email": "js@gitlabhq.com", "email": "js@gitlabhq.com",
"event_name": "user_create", "event_name": "user_create",
"name": "John Smith", "name": "John Smith",
"username": "js",
"user_id": 41 "user_id": 41
} }
``` ```
@ -142,6 +143,7 @@ X-Gitlab-Event: System Hook
"email": "js@gitlabhq.com", "email": "js@gitlabhq.com",
"event_name": "user_destroy", "event_name": "user_destroy",
"name": "John Smith", "name": "John Smith",
"username": "js",
"user_id": 41 "user_id": 41
} }
``` ```

View file

@ -9,8 +9,8 @@ describe SystemHooksService, services: true do
let(:group_member) { create(:group_member) } let(:group_member) { create(:group_member) }
context 'event data' do context 'event data' do
it { expect(event_data(user, :create)).to include(:event_name, :name, :created_at, :updated_at, :email, :user_id) } it { expect(event_data(user, :create)).to include(:event_name, :name, :created_at, :updated_at, :email, :user_id, :username) }
it { expect(event_data(user, :destroy)).to include(:event_name, :name, :created_at, :updated_at, :email, :user_id) } it { expect(event_data(user, :destroy)).to include(:event_name, :name, :created_at, :updated_at, :email, :user_id, :username) }
it { expect(event_data(project, :create)).to include(:event_name, :name, :created_at, :updated_at, :path, :project_id, :owner_name, :owner_email, :project_visibility) } it { expect(event_data(project, :create)).to include(:event_name, :name, :created_at, :updated_at, :path, :project_id, :owner_name, :owner_email, :project_visibility) }
it { expect(event_data(project, :destroy)).to include(:event_name, :name, :created_at, :updated_at, :path, :project_id, :owner_name, :owner_email, :project_visibility) } it { expect(event_data(project, :destroy)).to include(:event_name, :name, :created_at, :updated_at, :path, :project_id, :owner_name, :owner_email, :project_visibility) }
it { expect(event_data(project_member, :create)).to include(:event_name, :created_at, :updated_at, :project_name, :project_path, :project_path_with_namespace, :project_id, :user_name, :user_email, :access_level, :project_visibility) } it { expect(event_data(project_member, :create)).to include(:event_name, :created_at, :updated_at, :project_name, :project_path, :project_path_with_namespace, :project_id, :user_name, :user_email, :access_level, :project_visibility) }