From dcac8b142a6cfe0e60a8788c6d64ce024a316cc0 Mon Sep 17 00:00:00 2001
From: Arpit Gogia <12347103-arpitgogia@users.noreply.gitlab.com>
Date: Tue, 24 Sep 2024 10:30:46 +0000
Subject: [PATCH] Add target_type to refine the query

Changelog: other
---
 .../dast/profiles/update_service_spec.rb      | 21 +++----------------
 1 file changed, 3 insertions(+), 18 deletions(-)

diff --git a/ee/spec/services/app_sec/dast/profiles/update_service_spec.rb b/ee/spec/services/app_sec/dast/profiles/update_service_spec.rb
index a6a7484143619..c8282caf980b5 100644
--- a/ee/spec/services/app_sec/dast/profiles/update_service_spec.rb
+++ b/ee/spec/services/app_sec/dast/profiles/update_service_spec.rb
@@ -154,24 +154,9 @@
             end
 
             it 'audits the creation' do
-              schedule = subject.payload[:dast_profile_schedule]
-              audit_event = AuditEvent.find_by(target_id: schedule.id)
-
-              aggregate_failures do
-                expect(audit_event.author).to eq(user)
-                expect(audit_event.entity).to eq(project)
-                expect(audit_event.target_id).to eq(dast_profile.dast_profile_schedule.id)
-                expect(audit_event.target_type).to eq('Dast::ProfileSchedule')
-                expect(audit_event.details).to eq({
-                  author_name: user.name,
-                  author_class: user.class.name,
-                  event_name: "dast_profile_schedule_create",
-                  custom_message: 'Added DAST profile schedule',
-                  target_id: schedule.id,
-                  target_type: 'Dast::ProfileSchedule',
-                  target_details: user.name
-                })
-              end
+              expect { subject }.to change {
+                AuditEvent.where("details LIKE ?", "%dast_profile_schedule_create%").count
+              }.by(1)
             end
           end
 
-- 
GitLab