Commit 31b0e149 authored by Alex's avatar Alex

Adding project visibility to system hooks

parent c355b9ab
...@@ -31,7 +31,8 @@ class SystemHooksService ...@@ -31,7 +31,8 @@ class SystemHooksService
path_with_namespace: model.path_with_namespace, path_with_namespace: model.path_with_namespace,
project_id: model.id, project_id: model.id,
owner_name: owner.name, owner_name: owner.name,
owner_email: owner.respond_to?(:email) ? owner.email : nil owner_email: owner.respond_to?(:email) ? owner.email : nil,
project_visibility: Project.visibility_levels.key(model.visibility_level_field).downcase
}) })
when User when User
data.merge!({ data.merge!({
...@@ -46,7 +47,8 @@ class SystemHooksService ...@@ -46,7 +47,8 @@ class SystemHooksService
project_id: model.project_id, project_id: model.project_id,
user_name: model.user.name, user_name: model.user.name,
user_email: model.user.email, user_email: model.user.email,
project_access: model.human_access project_access: model.human_access,
project_visibility: Project.visibility_levels.key(model.project.visibility_level_field).downcase
}) })
end end
end end
......
...@@ -16,6 +16,7 @@ System hooks can be used, e.g. for logging or changing information in a LDAP ser ...@@ -16,6 +16,7 @@ System hooks can be used, e.g. for logging or changing information in a LDAP ser
"path": "stormcloud", "path": "stormcloud",
"path_with_namespace": "jsmith/stormcloud", "path_with_namespace": "jsmith/stormcloud",
"project_id": 74, "project_id": 74,
"project_visibility": "private",
} }
``` ```
...@@ -31,6 +32,7 @@ System hooks can be used, e.g. for logging or changing information in a LDAP ser ...@@ -31,6 +32,7 @@ System hooks can be used, e.g. for logging or changing information in a LDAP ser
"path": "underscore", "path": "underscore",
"path_with_namespace": "jsmith/underscore", "path_with_namespace": "jsmith/underscore",
"project_id": 73, "project_id": 73,
"project_visibility": "internal",
} }
``` ```
...@@ -38,14 +40,15 @@ System hooks can be used, e.g. for logging or changing information in a LDAP ser ...@@ -38,14 +40,15 @@ System hooks can be used, e.g. for logging or changing information in a LDAP ser
```json ```json
{ {
"created_at": "2012-07-21T07:30:56Z", "created_at": "2012-07-21T07:30:56Z",
"event_name": "user_add_to_team", "event_name": "user_add_to_team",
"project_access": "Master", "project_access": "Master",
"project_id": 74, "project_id": 74,
"project_name": "StoreCloud", "project_name": "StoreCloud",
"project_path": "storecloud", "project_path": "storecloud",
"user_email": "johnsmith@gmail.com", "user_email": "johnsmith@gmail.com",
"user_name": "John Smith", "user_name": "John Smith",
"project_visibility": "private",
} }
``` ```
...@@ -53,14 +56,15 @@ System hooks can be used, e.g. for logging or changing information in a LDAP ser ...@@ -53,14 +56,15 @@ System hooks can be used, e.g. for logging or changing information in a LDAP ser
```json ```json
{ {
"created_at": "2012-07-21T07:30:56Z", "created_at": "2012-07-21T07:30:56Z",
"event_name": "user_remove_from_team", "event_name": "user_remove_from_team",
"project_access": "Master", "project_access": "Master",
"project_id": 74, "project_id": 74,
"project_name": "StoreCloud", "project_name": "StoreCloud",
"project_path": "storecloud", "project_path": "storecloud",
"user_email": "johnsmith@gmail.com", "user_email": "johnsmith@gmail.com",
"user_name": "John Smith", "user_name": "John Smith",
"project_visibility": "private",
} }
``` ```
......
...@@ -8,10 +8,10 @@ describe SystemHooksService do ...@@ -8,10 +8,10 @@ describe SystemHooksService do
context 'event data' do context 'event data' do
it { event_data(user, :create).should include(:event_name, :name, :created_at, :email, :user_id) } it { event_data(user, :create).should include(:event_name, :name, :created_at, :email, :user_id) }
it { event_data(user, :destroy).should include(:event_name, :name, :created_at, :email, :user_id) } it { event_data(user, :destroy).should include(:event_name, :name, :created_at, :email, :user_id) }
it { event_data(project, :create).should include(:event_name, :name, :created_at, :path, :project_id, :owner_name, :owner_email) } it { event_data(project, :create).should include(:event_name, :name, :created_at, :path, :project_id, :owner_name, :owner_email, :project_visibility) }
it { event_data(project, :destroy).should include(:event_name, :name, :created_at, :path, :project_id, :owner_name, :owner_email) } it { event_data(project, :destroy).should include(:event_name, :name, :created_at, :path, :project_id, :owner_name, :owner_email, :project_visibility) }
it { event_data(users_project, :create).should include(:event_name, :created_at, :project_name, :project_path, :project_id, :user_name, :user_email, :project_access) } it { event_data(users_project, :create).should include(:event_name, :created_at, :project_name, :project_path, :project_id, :user_name, :user_email, :project_access, :project_visibility) }
it { event_data(users_project, :destroy).should include(:event_name, :created_at, :project_name, :project_path, :project_id, :user_name, :user_email, :project_access) } it { event_data(users_project, :destroy).should include(:event_name, :created_at, :project_name, :project_path, :project_id, :user_name, :user_email, :project_access, :project_visibility) }
end end
context 'event names' do context 'event names' do
......
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