-
-
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
Do not overwrite the dafault value #1680
Labels
Comments
a quick script we threw together to test this out...
|
The issue with with aliases is popping up every now and then, recent with #1142 - where one suggestion is to use transient to work around this edge case. # following factory passes above example
FactoryBot.define do
factory :realtor do
# duplicate { false }
# duplicate_id { "This should exist" }
transient do
duplicate { false }
duplicate_id { "This should exist" }
end
initialize_with do
new(attributes.merge(duplicate:, duplicate_id:))
end
end
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Description
So, it does not set any value from factory neither from wrote manually
Reproduction Steps
Create the realtors table with the duplicate_id column.
Define a factory for realtor with a duplicate_id attribute.
Create a realtor object in a test, specifying a value for duplicate_id.
Check the value of duplicate_id on the created object; it is nil instead of the expected value.
Expected behavior
The duplicate_id should be set to the value specified manually in the test when creating a realtor object.
Actual behavior
The duplicate_id is set to nil, ignoring both the factory-generated value and the manually specified value.
System configuration
factory_bot_rails (6.2.0):
rails (7.0.8):
ruby (3.2.1):
The text was updated successfully, but these errors were encountered: