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

uniqueness: don't use a private Rails API #995

Merged
merged 1 commit into from Jul 11, 2020

Conversation

alyssais
Copy link
Contributor

ActiveRecord::Validations#_validations is a private API.

Fortunately, Rails provides an API that does exactly what's needed here, and it's been in Rails since at least 3.0.0, so let's use that instead.


I ran into an issue using shoulda-matchers with schema_validations. It overrides the public ActiveModel::Validations methods to dynamically add validations based on the database schema. Since shoulda-matchers accesses validations using a private API, it incorrectly causes test failures.

@@ -381,7 +381,7 @@ def description_for_case_sensitive_qualifier
end

def validations
model._validators[@attribute].select do |validator|
model.validators_on(@attribute).select do |validator|

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mcmire
Copy link
Collaborator

mcmire commented May 6, 2020

Hey folks. In an effort to lighten our load as maintainers and be able to serve you better in the future, the shoulda-matchers team is working on cleaning out the cobwebs in this repo by pruning the backlog. As there are few of us, there are a lot of items that will simply never earn our attention in a reasonable time frame, and rather than giving you an empty promise, we think it makes more sense to focus on more recent issues. That means, unfortunately, that we must close this PR.

Don't take this the wrong way: our aim is not to diminish the effort people have made or dismiss problems that have been raised. If you feel that we should reopen this PR, then please let us know so that we can reprioritize it. Thanks!

@mcmire mcmire closed this May 6, 2020
@alyssais
Copy link
Contributor Author

alyssais commented May 7, 2020 via email

@mcmire
Copy link
Collaborator

mcmire commented May 7, 2020

Ok!

@mcmire mcmire reopened this May 7, 2020
`ActiveRecord::Validations#_validations` is a private API.

Fortunately, Rails provides an API that does exactly what's needed here,
and it's been in Rails since at least 3.0.0, so let's use that instead.
@mcmire mcmire merged commit 47ca467 into thoughtbot:master Jul 11, 2020
@mcmire
Copy link
Collaborator

mcmire commented Jul 11, 2020

I apologize it took me so long to merge this — this is in master now.

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

Successfully merging this pull request may close these issues.

None yet

3 participants