Create a dev:populate task to add fake data to your dev environment#3101
Create a dev:populate task to add fake data to your dev environment#3101gravitystorm wants to merge 5 commits intoopenstreetmap:masterfrom
Conversation
e7e1af2 to
7eac2fc
Compare
|
Does anyone have any feedback on this PR, or #3030? Useful, not useful, good approach, etc? |
|
I was just giving this I was pondering whether the naming But anyway... looks good to me |
Great, thanks for testing it out! Glad to hear that it worked.
The I'm happy to rename |
|
Ah. That all make sense yes. I have some recent experience of having many rake tasks in a bit of a mess, but we're long way off that here anyway. |
It can be quite time consuming to add data, such as diary entries, notes, and users to your development database. This is a basic implementation of an idempotent rake task that does some of the hard work for you.
…nt environment We don't want any FactoryBot stuff available in production, and this shouldn't be used by mistake in the test environment either.
7eac2fc to
37ac6b8
Compare
|
Rebased to resolve merge conflicts. |
|
I'm currently also in need of a dummy user account, because I cannot easily create it via the web interface since the server is running in a docker instance on Github actions. I first tried the following approach which is a modified version from this issue: #3136 But when trying this on my local server I cannot login via the website (server log.txt) In your approach the user name (and password?) seems to be generated and thus (kind of) unknown. For my use case it would be nice to have a fixed user account, with known name and password. Thanks in advance. My use case: |
|
All right, took me a while, but now I've got a basic idea of how the The code below is now working for me. |
|
I think this can be closed after the merge of #6432 |
|
It certainly covers similar enough ground that I'm happy to close this! I'll look at introducing faker, using factorybot for creating objects, etc, in a fresh PR. |
This is an alternative approach to #3030 with the same overall goal. It's based on the approach that I outlined there, namely being idempotent, and using Faker and FactoryBot to cut down on the code required, and being a separate task so that there's no overlap between (expected) seed data and (optional) dev data.
@tordans what do you think? If you have the chance to try this out, and see if it would work as the basis for what you were trying to do, that would be great.
At the moment it only creates one user and one diary entry, since it was piecing together the FactoryBot strategy along with the steps to achieve idempotency that was the bulk of the work in this PR. I'm hoping that it's straightforward to expand to more data.