BigW Consortium Gitlab

Unverified Commit 32a5b741 by Dmitriy Zaporozhets

Merge branch 'add_username_to_user_system_hooks' of https://github.com/tbeadle/gitlabhq

parents 678ee247 1f64332e
...@@ -47,7 +47,8 @@ class SystemHooksService ...@@ -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))
...@@ -99,6 +100,7 @@ class SystemHooksService ...@@ -99,6 +100,7 @@ class SystemHooksService
project_path: model.project.path, project_path: model.project.path,
project_path_with_namespace: model.project.path_with_namespace, project_path_with_namespace: model.project.path_with_namespace,
project_id: model.project.id, project_id: model.project.id,
user_username: model.user.username,
user_name: model.user.name, user_name: model.user.name,
user_email: model.user.email, user_email: model.user.email,
user_id: model.user.id, user_id: model.user.id,
...@@ -112,6 +114,7 @@ class SystemHooksService ...@@ -112,6 +114,7 @@ class SystemHooksService
group_name: model.group.name, group_name: model.group.name,
group_path: model.group.path, group_path: model.group.path,
group_id: model.group.id, group_id: model.group.id,
user_username: model.user.username,
user_name: model.user.name, user_name: model.user.name,
user_email: model.user.email, user_email: model.user.email,
user_id: model.user.id, user_id: model.user.id,
......
...@@ -96,6 +96,7 @@ X-Gitlab-Event: System Hook ...@@ -96,6 +96,7 @@ X-Gitlab-Event: System Hook
"project_path_with_namespace": "jsmith/storecloud", "project_path_with_namespace": "jsmith/storecloud",
"user_email": "johnsmith@gmail.com", "user_email": "johnsmith@gmail.com",
"user_name": "John Smith", "user_name": "John Smith",
"user_username": "johnsmith",
"user_id": 41, "user_id": 41,
"project_visibility": "private", "project_visibility": "private",
} }
...@@ -115,6 +116,7 @@ X-Gitlab-Event: System Hook ...@@ -115,6 +116,7 @@ X-Gitlab-Event: System Hook
"project_path_with_namespace": "jsmith/storecloud", "project_path_with_namespace": "jsmith/storecloud",
"user_email": "johnsmith@gmail.com", "user_email": "johnsmith@gmail.com",
"user_name": "John Smith", "user_name": "John Smith",
"user_username": "johnsmith",
"user_id": 41, "user_id": 41,
"project_visibility": "private", "project_visibility": "private",
} }
...@@ -129,6 +131,7 @@ X-Gitlab-Event: System Hook ...@@ -129,6 +131,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 +145,7 @@ X-Gitlab-Event: System Hook ...@@ -142,6 +145,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
} }
``` ```
...@@ -215,6 +219,7 @@ X-Gitlab-Event: System Hook ...@@ -215,6 +219,7 @@ X-Gitlab-Event: System Hook
"group_path": "storecloud", "group_path": "storecloud",
"user_email": "johnsmith@gmail.com", "user_email": "johnsmith@gmail.com",
"user_name": "John Smith", "user_name": "John Smith",
"user_username": "johnsmith",
"user_id": 41 "user_id": 41
} }
``` ```
...@@ -231,6 +236,7 @@ X-Gitlab-Event: System Hook ...@@ -231,6 +236,7 @@ X-Gitlab-Event: System Hook
"group_path": "storecloud", "group_path": "storecloud",
"user_email": "johnsmith@gmail.com", "user_email": "johnsmith@gmail.com",
"user_name": "John Smith", "user_name": "John Smith",
"user_username": "johnsmith",
"user_id": 41 "user_id": 41
} }
``` ```
...@@ -9,54 +9,54 @@ describe SystemHooksService, services: true do ...@@ -9,54 +9,54 @@ 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, :user_id, :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_username, :user_email, :user_id, :access_level, :project_visibility) }
it { expect(event_data(project_member, :destroy)).to include(:event_name, :created_at, :updated_at, :project_name, :project_path, :project_path_with_namespace, :project_id, :user_name, :user_email, :user_id, :access_level, :project_visibility) } it { expect(event_data(project_member, :destroy)).to include(:event_name, :created_at, :updated_at, :project_name, :project_path, :project_path_with_namespace, :project_id, :user_name, :user_username, :user_email, :user_id, :access_level, :project_visibility) }
it { expect(event_data(key, :create)).to include(:username, :key, :id) } it { expect(event_data(key, :create)).to include(:username, :key, :id) }
it { expect(event_data(key, :destroy)).to include(:username, :key, :id) } it { expect(event_data(key, :destroy)).to include(:username, :key, :id) }
it do it do
project.old_path_with_namespace = 'renamed_from_path' project.old_path_with_namespace = 'renamed_from_path'
expect(event_data(project, :rename)).to include( expect(event_data(project, :rename)).to include(
:event_name, :name, :created_at, :updated_at, :path, :project_id, :event_name, :name, :created_at, :updated_at, :path, :project_id,
:owner_name, :owner_email, :project_visibility, :owner_name, :owner_email, :project_visibility,
:old_path_with_namespace :old_path_with_namespace
) )
end end
it do it do
project.old_path_with_namespace = 'transfered_from_path' project.old_path_with_namespace = 'transfered_from_path'
expect(event_data(project, :transfer)).to include( expect(event_data(project, :transfer)).to include(
:event_name, :name, :created_at, :updated_at, :path, :project_id, :event_name, :name, :created_at, :updated_at, :path, :project_id,
:owner_name, :owner_email, :project_visibility, :owner_name, :owner_email, :project_visibility,
:old_path_with_namespace :old_path_with_namespace
) )
end end
it do it do
expect(event_data(group, :create)).to include( expect(event_data(group, :create)).to include(
:event_name, :name, :created_at, :updated_at, :path, :group_id, :event_name, :name, :created_at, :updated_at, :path, :group_id,
:owner_name, :owner_email :owner_name, :owner_email
) )
end end
it do it do
expect(event_data(group, :destroy)).to include( expect(event_data(group, :destroy)).to include(
:event_name, :name, :created_at, :updated_at, :path, :group_id, :event_name, :name, :created_at, :updated_at, :path, :group_id,
:owner_name, :owner_email :owner_name, :owner_email
) )
end end
it do it do
expect(event_data(group_member, :create)).to include( expect(event_data(group_member, :create)).to include(
:event_name, :created_at, :updated_at, :group_name, :group_path, :event_name, :created_at, :updated_at, :group_name, :group_path,
:group_id, :user_id, :user_name, :user_email, :group_access :group_id, :user_id, :user_username, :user_name, :user_email, :group_access
) )
end end
it do it do
expect(event_data(group_member, :destroy)).to include( expect(event_data(group_member, :destroy)).to include(
:event_name, :created_at, :updated_at, :group_name, :group_path, :event_name, :created_at, :updated_at, :group_name, :group_path,
:group_id, :user_id, :user_name, :user_email, :group_access :group_id, :user_id, :user_username, :user_name, :user_email, :group_access
) )
end end
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