Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Generate unique references in organisation factory
Use Faker's `unique` feature to guarantee unique strings for the `iati_reference` and `beis_organisation_reference` in the organisation factory. We have seen the test suite fail with an intermittent failure, unrelated to actual code failure, caused by the organisation created failing the uniqueness check for its `iati_reference`: ``` ActiveRecord::RecordInvalid: Validation failed: Iati reference Iati reference has already been taken ``` E.g. https://github.com/UKGovernmentBEIS/beis-report-official-development-assistance/actions/runs/6978961311/job/18991313569 We suspect this intermittent failure is caused by Faker's pseudo-random generator accidentally producing the same string within the same spec. The IATI reference and BEIS organisation reference are more susceptible to this, because the randomly generated sequences are only 5 characters long. Using Faker's unique feature means it's also a good idea to clear the record of unique values that have been returned between each spec, to avoid running out of combinations. (Not statistically likely, but why take chances?)
- Loading branch information