Skip to content

Fix flaky specs in AutocompleteSourcesController

Abdul Wadood requested to merge 444816-do-not-use-hard-coded-ids into master

What does this MR do and why?

Fix flaky specs in AutocompleteSourcesController

These specs were failing with the following error in our pipelines:

ActiveRecord::RecordNotUnique:
        PG::UniqueViolation: ERROR:  duplicate key value violates unique constraint "issues_pkey"
        DETAIL:  Key (id)=(1) already exists.

Because we were using hardcoded IDs. It doesn't fail locally because the issues table in the test database would have its sequence set at more than 1. But in the pipeline, we get a fresh database every time so the sequence starts at 1 and it fails.

MR acceptance checklist

Please evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.

How to set up and validate locally

You can reproduce the same behavior locally by running the following command in gdk psql -d gitlabhq_test:

ALTER SEQUENCE issues_id_seq RESTART WITH 1;

And then run the spec.

Related to #444816 (closed)

Merge request reports