diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-04-20 13:00:54 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-04-20 13:00:54 +0300 |
commit | 3cccd102ba543e02725d247893729e5c73b38295 (patch) | |
tree | f36a04ec38517f5deaaacb5acc7d949688d1e187 /spec/services/audit_event_service_spec.rb | |
parent | 205943281328046ef7b4528031b90fbda70c75ac (diff) |
Add latest changes from gitlab-org/gitlab@14-10-stable-eev14.10.0-rc42
Diffstat (limited to 'spec/services/audit_event_service_spec.rb')
-rw-r--r-- | spec/services/audit_event_service_spec.rb | 28 |
1 files changed, 25 insertions, 3 deletions
diff --git a/spec/services/audit_event_service_spec.rb b/spec/services/audit_event_service_spec.rb index 0379fd3f05c..6963515ba5c 100644 --- a/spec/services/audit_event_service_spec.rb +++ b/spec/services/audit_event_service_spec.rb @@ -17,7 +17,8 @@ RSpec.describe AuditEventService do author_name: user.name, entity_id: project.id, entity_type: "Project", - action: :destroy) + action: :destroy, + created_at: anything) expect { service.security_event }.to change(AuditEvent, :count).by(1) end @@ -39,7 +40,8 @@ RSpec.describe AuditEventService do from: 'true', to: 'false', action: :create, - target_id: 1) + target_id: 1, + created_at: anything) expect { service.security_event }.to change(AuditEvent, :count).by(1) @@ -50,6 +52,25 @@ RSpec.describe AuditEventService do expect(details[:target_id]).to eq(1) end + context 'when defining created_at manually' do + let(:service) { described_class.new(user, project, { action: :destroy }, :database, 3.weeks.ago) } + + it 'is overridden successfully' do + freeze_time do + expect(service).to receive(:file_logger).and_return(logger) + expect(logger).to receive(:info).with(author_id: user.id, + author_name: user.name, + entity_id: project.id, + entity_type: "Project", + action: :destroy, + created_at: 3.weeks.ago) + + expect { service.security_event }.to change(AuditEvent, :count).by(1) + expect(AuditEvent.last.created_at).to eq(3.weeks.ago) + end + end + end + context 'authentication event' do let(:audit_service) { described_class.new(user, user, with: 'standard') } @@ -110,7 +131,8 @@ RSpec.describe AuditEventService do author_name: user.name, entity_type: 'Project', entity_id: project.id, - action: :destroy) + action: :destroy, + created_at: anything) service.log_security_event_to_file end |