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

have_many(:model).validate(false) causes a false positive test #1357

Closed
kiskoza opened this issue Sep 17, 2020 · 1 comment · Fixed by #1378
Closed

have_many(:model).validate(false) causes a false positive test #1357

kiskoza opened this issue Sep 17, 2020 · 1 comment · Fixed by #1378
Assignees

Comments

@kiskoza
Copy link

kiskoza commented Sep 17, 2020

I run into a problem where I had to make sure that an association has a validate: false on the association. I started it with writing a test for it, but it passed immediately without making the required code change.

I created this code snippet to reproduce the issue: https://gist.github.com/kiskoza/da2b4a0ba6930e9454403ea36e3fd73c

I think the problem is that in my case there weren't a validate option prior to the task. When it was validated as a boolean, the nil value was simply converted to false

Docs about the validate option: https://apidock.com/rails/ActiveRecord/Associations/ClassMethods/has_many

@vsppedro
Copy link
Collaborator

vsppedro commented Nov 19, 2020

Hi, @kiskoza , thank you very much for all this information. The description of this issue helped me a lot.

This fix will be available on the next release.

Thank you!

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