librariesio / libraries.io

:books: The Open Source Discovery Service
https://libraries.io
GNU Affero General Public License v3.0
1.1k stars 206 forks source link

Remove unnecessary/broken validations on Repository{User,Organisation} #3273

Closed tiegz closed 7 months ago

tiegz commented 7 months ago

this removes 4 uniqueness validations on RepositoryUser and RepositoryOrganisation.

the two "host_type/login" validations were broken because they don't work for the case where a login changes case (e.g. "FOO" -> "foo"). Another reason is that unique indices already exist for these column pairs (uuid/host_type) (lower(host_type)/lower(login)), so we don't need extra ruby logic to handle these.

in these scenarios, we'll now get a ActiveRecord::RecordNotUnique ... PG::UniqueViolation: ERROR: duplicate key value ... error instead of ActiveRecord::RecordInvalid ... Validation failed: Login must be unique

fixes bugsnag 656e06f8feff8200073ef0cd

macowie commented 7 months ago

Ope, there's a shoulda matcher test for this validation in RepositoryOrganisation spec