Commit 31b0e14981d57c2f38734872181c6dc49a2e6f5a
1 parent
c355b9ab
Exists in
spb-stable
and in
2 other branches
Adding project visibility to system hooks
Showing
3 changed files
with
28 additions
and
22 deletions
Show diff stats
app/services/system_hooks_service.rb
| ... | ... | @@ -31,7 +31,8 @@ class SystemHooksService |
| 31 | 31 | path_with_namespace: model.path_with_namespace, |
| 32 | 32 | project_id: model.id, |
| 33 | 33 | owner_name: owner.name, |
| 34 | - owner_email: owner.respond_to?(:email) ? owner.email : nil | |
| 34 | + owner_email: owner.respond_to?(:email) ? owner.email : nil, | |
| 35 | + project_visibility: Project.visibility_levels.key(model.visibility_level_field).downcase | |
| 35 | 36 | }) |
| 36 | 37 | when User |
| 37 | 38 | data.merge!({ |
| ... | ... | @@ -46,7 +47,8 @@ class SystemHooksService |
| 46 | 47 | project_id: model.project_id, |
| 47 | 48 | user_name: model.user.name, |
| 48 | 49 | user_email: model.user.email, |
| 49 | - project_access: model.human_access | |
| 50 | + project_access: model.human_access, | |
| 51 | + project_visibility: Project.visibility_levels.key(model.project.visibility_level_field).downcase | |
| 50 | 52 | }) |
| 51 | 53 | end |
| 52 | 54 | end | ... | ... |
doc/system_hooks/system_hooks.md
| ... | ... | @@ -16,6 +16,7 @@ System hooks can be used, e.g. for logging or changing information in a LDAP ser |
| 16 | 16 | "path": "stormcloud", |
| 17 | 17 | "path_with_namespace": "jsmith/stormcloud", |
| 18 | 18 | "project_id": 74, |
| 19 | + "project_visibility": "private", | |
| 19 | 20 | } |
| 20 | 21 | ``` |
| 21 | 22 | |
| ... | ... | @@ -31,6 +32,7 @@ System hooks can be used, e.g. for logging or changing information in a LDAP ser |
| 31 | 32 | "path": "underscore", |
| 32 | 33 | "path_with_namespace": "jsmith/underscore", |
| 33 | 34 | "project_id": 73, |
| 35 | + "project_visibility": "internal", | |
| 34 | 36 | } |
| 35 | 37 | ``` |
| 36 | 38 | |
| ... | ... | @@ -38,14 +40,15 @@ System hooks can be used, e.g. for logging or changing information in a LDAP ser |
| 38 | 40 | |
| 39 | 41 | ```json |
| 40 | 42 | { |
| 41 | - "created_at": "2012-07-21T07:30:56Z", | |
| 42 | - "event_name": "user_add_to_team", | |
| 43 | - "project_access": "Master", | |
| 44 | - "project_id": 74, | |
| 45 | - "project_name": "StoreCloud", | |
| 46 | - "project_path": "storecloud", | |
| 47 | - "user_email": "johnsmith@gmail.com", | |
| 48 | - "user_name": "John Smith", | |
| 43 | + "created_at": "2012-07-21T07:30:56Z", | |
| 44 | + "event_name": "user_add_to_team", | |
| 45 | + "project_access": "Master", | |
| 46 | + "project_id": 74, | |
| 47 | + "project_name": "StoreCloud", | |
| 48 | + "project_path": "storecloud", | |
| 49 | + "user_email": "johnsmith@gmail.com", | |
| 50 | + "user_name": "John Smith", | |
| 51 | + "project_visibility": "private", | |
| 49 | 52 | } |
| 50 | 53 | ``` |
| 51 | 54 | |
| ... | ... | @@ -53,14 +56,15 @@ System hooks can be used, e.g. for logging or changing information in a LDAP ser |
| 53 | 56 | |
| 54 | 57 | ```json |
| 55 | 58 | { |
| 56 | - "created_at": "2012-07-21T07:30:56Z", | |
| 57 | - "event_name": "user_remove_from_team", | |
| 58 | - "project_access": "Master", | |
| 59 | - "project_id": 74, | |
| 60 | - "project_name": "StoreCloud", | |
| 61 | - "project_path": "storecloud", | |
| 62 | - "user_email": "johnsmith@gmail.com", | |
| 63 | - "user_name": "John Smith", | |
| 59 | + "created_at": "2012-07-21T07:30:56Z", | |
| 60 | + "event_name": "user_remove_from_team", | |
| 61 | + "project_access": "Master", | |
| 62 | + "project_id": 74, | |
| 63 | + "project_name": "StoreCloud", | |
| 64 | + "project_path": "storecloud", | |
| 65 | + "user_email": "johnsmith@gmail.com", | |
| 66 | + "user_name": "John Smith", | |
| 67 | + "project_visibility": "private", | |
| 64 | 68 | } |
| 65 | 69 | ``` |
| 66 | 70 | ... | ... |
spec/services/system_hooks_service_spec.rb
| ... | ... | @@ -8,10 +8,10 @@ describe SystemHooksService do |
| 8 | 8 | context 'event data' do |
| 9 | 9 | it { event_data(user, :create).should include(:event_name, :name, :created_at, :email, :user_id) } |
| 10 | 10 | it { event_data(user, :destroy).should include(:event_name, :name, :created_at, :email, :user_id) } |
| 11 | - it { event_data(project, :create).should include(:event_name, :name, :created_at, :path, :project_id, :owner_name, :owner_email) } | |
| 12 | - it { event_data(project, :destroy).should include(:event_name, :name, :created_at, :path, :project_id, :owner_name, :owner_email) } | |
| 13 | - it { event_data(users_project, :create).should include(:event_name, :created_at, :project_name, :project_path, :project_id, :user_name, :user_email, :project_access) } | |
| 14 | - it { event_data(users_project, :destroy).should include(:event_name, :created_at, :project_name, :project_path, :project_id, :user_name, :user_email, :project_access) } | |
| 11 | + it { event_data(project, :create).should include(:event_name, :name, :created_at, :path, :project_id, :owner_name, :owner_email, :project_visibility) } | |
| 12 | + it { event_data(project, :destroy).should include(:event_name, :name, :created_at, :path, :project_id, :owner_name, :owner_email, :project_visibility) } | |
| 13 | + 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) } | |
| 14 | + 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) } | |
| 15 | 15 | end |
| 16 | 16 | |
| 17 | 17 | context 'event names' do | ... | ... |