Repository navigation
[5.3] Create factory modifiers - #14241
Merged
Merged
Conversation
Contributor
|
See Multiple Factory Types in Model Factories |
Contributor
Author
|
thanks, I am aware of the multiple factories types. unfortunately, unless I'm mistaken, they don't allow you to apply multiple 'modifications' to the factory. |
Contributor
Author
|
wondering if there are any thoughts on this? |
Contributor
Author
|
am i supposed to fix this @GrahamCampbell or do we let StyleCI handle it afterwards? |
Collaborator
|
Yeh, don't worry about StyleCI. :) |
Contributor
|
Looking forward to this, pretty neat! |
Member
|
Sorry this took so long. I renamed "modifiers" to "states"... pretty much works the same though 👍 |
Contributor
|
@browner12: Nice! Could you update the docs as well? |
Contributor
Author
|
no problem. glad it worked out. was just going to ask, @taylorotwell would you like me to PR a docs update? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
i've come to find that I would would like to use factories a little different than is currently available. Currently you can
defineanddefineAsfactories. This works okay, but where I run into issues is where I have a lot of variable types. For example, I may have aBlogthat has apublished_atfield and anuser_idfield. TheBlogcan be published or unpublished, and it can have an author or be written by anonymous. I could have a published authored Blog, an unpublished authored Blog, a published anonymous Blog, and an unpublished anonymous Blog. Currently, I would have to write 5 different factory types for this.Ideally what I would like is 'modifiers' for each factory. To define them I would:
This would allow me to mix and match modifiers as needed. Then to use the factories I would
I believe this offers a lot more flexibility, and still allows people to do it the current way if they prefer.