Open mikecann opened 4 years ago
Sorry for being late. So (if I get this right) basically you only want this for testing, so you can resolve references without a root model?
Ye pretty much. I was sharing and checking I wasnt doing anything really dumb by doing this. If its not an issue you have encountered tho its okay ill close the issue :)
Sounds useful. I'd change the name to something that makes its usage more obvious (e.g. testRef). Are you willing to create a PR?
Well I dont want to add stuff to bloat the lib if im the only one likely to use it..
Also testRef, im less sure about that name as there is nothing inherently neccessary about it being in test code is there? It can just be used in normal code with multiple roots? Tho im not sure how snapshotting would work there..
Oh and yes I dont mind having a stab at a PR if you want, tho it might take a me a little while my new project is taking up a great deal of time at the mo :P
When testing keystone models that have "ref" properties it can be tedious to have to setup a root model that contains the referenced model before testing the referencing model so I think some sort of "directRef" is useful.
Its basically just a customRef:
And heres some tests explaining what I mean and how I like to use it:
Thoughts? Is this a good idea? Is there a better way of doing it than this?