Skip to content

Avoid company name collisions in CRM fixture

Stan Hu requested to merge sh-fix-issue-348229 into master

What does this MR do and why?

!76313 (merged) added a fixture that generated company names for every group in the system. It's not too hard to generate a collision (see below). We append an index to the name to ensure there's no chance of a name collision.

Closes #348229 (closed)

How to set up and validate locally

FILTER=crm bundle exec rake db:seed_fu

This is a little script to show how often a collision could be hit:

require 'ffaker'

keys = {}
count = 0

loop do
  name = FFaker::Company.name

  if keys.key?(name)
    puts "got duplicate in #{count}"
    break
  end

  count += 1
  keys[name] = 1
end
$ while true; do ruby test.rb; done
got duplicate in 209
got duplicate in 116
got duplicate in 60
got duplicate in 186
got duplicate in 337
got duplicate in 221
got duplicate in 351
got duplicate in 201
got duplicate in 90
got duplicate in 78
got duplicate in 37
got duplicate in 197
got duplicate in 56
got duplicate in 175
got duplicate in 110
got duplicate in 61
got duplicate in 7
got duplicate in 93
got duplicate in 35
got duplicate in 188
got duplicate in 9
got duplicate in 201
got duplicate in 72
got duplicate in 131
got duplicate in 125
got duplicate in 151
got duplicate in 260
got duplicate in 234
got duplicate in 241
got duplicate in 199

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 Stan Hu

Merge request reports