Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Case-sensitive uniqueness validation fails if default value lacks alpha characters #787

Closed
tovodeverett opened this issue Oct 4, 2015 · 1 comment

Comments

@tovodeverett
Copy link

I've run into a fairly unique situation, but I thought I'd bring it up in case someone wants to defend against it.

If your factory for generating objects uses a string that does not have change with swapcase (i.e. something like '%-1-%'), and you're doing a validate_uniqueness_of test without specifying case_insensitive, then you will get a rather confusing error message.

Perhaps it might make sense somewhere around https://github.com/thoughtbot/shoulda-matchers/blob/master/lib/shoulda/matchers/active_record/validate_uniqueness_of_matcher.rb#L410 to check to see that the swapcased value differs from the original value and if it doesn't to throw an error along the lines of, "if you're not doing a case_insensitive test, then you need to make sure your value here has alpha characters in it!".

@mcmire
Copy link
Collaborator

mcmire commented Oct 4, 2015

Moving discussion to #789.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants