diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-08-20 21:42:06 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-08-20 21:42:06 +0300 |
commit | 6e4e1050d9dba2b7b2523fdd1768823ab85feef4 (patch) | |
tree | 78be5963ec075d80116a932011d695dd33910b4e /spec/factories/audit_events.rb | |
parent | 1ce776de4ae122aba3f349c02c17cebeaa8ecf07 (diff) |
Add latest changes from gitlab-org/gitlab@13-3-stable-ee
Diffstat (limited to 'spec/factories/audit_events.rb')
-rw-r--r-- | spec/factories/audit_events.rb | 78 |
1 files changed, 78 insertions, 0 deletions
diff --git a/spec/factories/audit_events.rb b/spec/factories/audit_events.rb new file mode 100644 index 00000000000..38414400282 --- /dev/null +++ b/spec/factories/audit_events.rb @@ -0,0 +1,78 @@ +# frozen_string_literal: true + +FactoryBot.define do + factory :audit_event, class: 'SecurityEvent', aliases: [:user_audit_event] do + user + + transient { target_user { create(:user) } } + + entity_type { 'User' } + entity_id { target_user.id } + entity_path { target_user.full_path } + target_details { target_user.name } + ip_address { IPAddr.new '127.0.0.1' } + author_name { 'Jane Doe' } + details do + { + change: 'email address', + from: 'admin@gitlab.com', + to: 'maintainer@gitlab.com', + author_name: user.name, + target_id: target_user.id, + target_type: 'User', + target_details: target_user.name, + ip_address: '127.0.0.1', + entity_path: target_user.full_path + } + end + + trait :project_event do + transient { target_project { create(:project) } } + + entity_type { 'Project' } + entity_id { target_project.id } + entity_path { target_project.full_path } + target_details { target_project.name } + ip_address { IPAddr.new '127.0.0.1' } + details do + { + change: 'packges_enabled', + from: true, + to: false, + author_name: user.name, + target_id: target_project.id, + target_type: 'Project', + target_details: target_project.name, + ip_address: '127.0.0.1', + entity_path: target_project.full_path + } + end + end + + trait :group_event do + transient { target_group { create(:group) } } + + entity_type { 'Group' } + entity_id { target_group.id } + entity_path { target_group.full_path } + target_details { target_group.name } + ip_address { IPAddr.new '127.0.0.1' } + details do + { + change: 'project_creation_level', + from: nil, + to: 'Developers + Maintainers', + author_name: user.name, + target_id: target_group.id, + target_type: 'Group', + target_details: target_group.name, + ip_address: '127.0.0.1', + entity_path: target_group.full_path + } + end + end + + factory :project_audit_event, traits: [:project_event] + factory :group_audit_event, traits: [:group_event] + end +end |