-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
Parent factory with traits that call other traits uses trait from child factory #1716
Comments
Hi @EmilioCristalli, Love the reproduction steps ... made it much easier 👍 I've submitted a pull request that should fix this issue #1717 Have a look and see if it works for you? As it's relatively small, I'd love it if you could create a new branch, merge the request (or cut/paste the changes) and run your tests. Real world tests are a far better indication of success. 🫶 |
thanks for looking into this @CodeMeister!! your PR seems to fix the issue for me |
Hi @EmilioCristalli. It would be best to leave this issue open until the PR is merged. Otherwise, the team may think it was fixed by another solution. 🎉 |
lol i mentioned your PR fixes this issue in a PR to use a workaround in a private repo, and github automatically closed this issue when i merged it haha sorry about that, will reopen it |
Hehe, GitHub works in mysterious ways... Thanks for re-opening 👍 |
Description
Not sure if this is a bug or expected behavior, but it felt confusing to me.
I have a factory
A
with a traittrait_a
that calls another traittrait_b
.And I have another factory
B
that inherits fromA
and overridestrait_b
.If I first use factory
B
, then factoryA
starts usingtrait_b
fromB
whentrait_a
is called (probably more clear with the example below haha)Reproduction Steps
Expected behavior
The test should pass, because the parent factory should use the
with_content
trait from the parent factoryActual behavior
It fails, because it uses the
with_content
trait from the childtech_post
factorySystem configuration
factory_bot version: 6.5.0
rails version: 7.2.1
ruby version: 3.3.5
The text was updated successfully, but these errors were encountered: