2020-10-24 23:57:45 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
FactoryBot.define do
|
2020-11-24 15:15:51 +05:30
|
|
|
factory :audit_event, class: 'AuditEvent', aliases: [:user_audit_event] do
|
2020-10-24 23:57:45 +05:30
|
|
|
user
|
|
|
|
|
2021-01-29 00:20:46 +05:30
|
|
|
transient { target_user { association(:user) } }
|
2020-10-24 23:57:45 +05:30
|
|
|
|
|
|
|
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
|
2021-01-29 00:20:46 +05:30
|
|
|
transient { target_project { association(:project) } }
|
2020-10-24 23:57:45 +05:30
|
|
|
|
|
|
|
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
|
|
|
|
{
|
2020-11-24 15:15:51 +05:30
|
|
|
change: 'packages_enabled',
|
2020-10-24 23:57:45 +05:30
|
|
|
from: true,
|
|
|
|
to: false,
|
|
|
|
author_name: user.name,
|
|
|
|
target_id: target_project.id,
|
2021-03-11 19:13:27 +05:30
|
|
|
target_type: 'Project',
|
|
|
|
target_details: target_project.name,
|
|
|
|
ip_address: '127.0.0.1',
|
|
|
|
entity_path: target_project.full_path
|
|
|
|
}
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
trait :unauthenticated do
|
|
|
|
author_id { -1 }
|
|
|
|
details do
|
|
|
|
{
|
|
|
|
custom_message: 'Custom action',
|
|
|
|
author_name: 'An unauthenticated user',
|
|
|
|
target_id: target_project.id,
|
2020-10-24 23:57:45 +05:30
|
|
|
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
|
2021-01-29 00:20:46 +05:30
|
|
|
transient { target_group { association(:group) } }
|
2020-10-24 23:57:45 +05:30
|
|
|
|
|
|
|
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
|