-
-
Notifications
You must be signed in to change notification settings - Fork 43
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
Allow usage of relations in dependant attributes #48
Comments
Can you show an example? I'm not sure I understand. |
In the above code, I expected Does this make it any clearer? |
@alexandru-calinoiu kind of yes, a sample setup that shows the problem would be more helpful though. Are you saying that in this case |
I think the same problem, I want to create consistent entities for my tests. Example:
In my tests, I would like to be able to create valid factories by default (without passing attributes, and entities) to the factory call. I would like to be able to create a web_resource_content = Factory[:web_resource_content]
web_resource_content.uri == web_resource_content.resource_content.uri
# => true This is possible with FactoryBot like this: factory :web_resource_content do
uri { Faker::Internet.url }
web_resource { association :web_resource, uri: uri }
end I don't know if this is something that can be interested to have in this library. It could be using this syntax: Factory.define(:web_resource_content) do |f|
f.association(:web_resource) { |uri| { uri: uri } }
f.uri { fake(:internet, :url) }
end or Factory.define(:web_resource_content) do |f|
f.web_resource { |uri| association(:web_resource, attributes: { uri: uri }) }
f.uri { fake(:internet, :url) }
end I don't know the implementation details of the library, this is just an example from a consumer perspective. 🙂 |
Noticed that when using a relation as dependency in creating an attribute the relation always comes in nil, any way I can achieve this?
I have tables that have some of the data denormalized and some attributes need to have the same value on the entity and on the relation.
The text was updated successfully, but these errors were encountered: