Add spec to test preloader in audit events report service

What does this MR do and why?

resolves: #390533 (closed)

It was mentioned in a separate MR that the preloader was not being tested.

This commit adds a spec that does that.

If the preloader lines is removed, all of the existing specs still pass however the new spec fails with the following message:

Failure/Error: expect { described_class.new(params).csv_data.to_a }.not_to exceed_query_limit(control)

  Expected a maximum of 1 queries, got 2:

  Query Diff:
  -----------
  SELECT "users"."id", "users"."name", "users"."username" FROM "users"...
  -- (expected: 0, got: 1)
     WHERE "users"."id" IN (16, 18) ORDER BY "users"."id" ASC LIMIT 1000

Screenshots or screen recordings

N/A

How to set up and validate locally

  1. remove preloader line here
  2. run specs, the new spec should fail
  3. re-add the line. all specs should pass

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by Michael Becker

Merge request reports

Loading