eduqg / LifeToRemind

:notebook_with_decorative_cover: Rails website to help students to create career plans.
https://lifetoremindhub.herokuapp.com/
BSD 3-Clause "New" or "Revised" License
11 stars 15 forks source link

Add PlansHashImporter #10

Closed nathandonato closed 4 years ago

nathandonato commented 4 years ago

Partial https://github.com/eduqg/LifeToRemind/issues/3

This PR pulls the JSON import/model creation stuff out of PlansController and into a place called PlansHashImporter.

Regressions were avoided by having the entry-point class PlansHashImporter accept the same hash structure that the controller originally did (many models in the same JSON object) and by allowing the controller to still use the current_user.

It's important to note, though, that this PR also attempts to accommodate for future functionality. It adds individual importers for each of the models in question so instead of needing the full controller-like JSON object, you can seed each object independently. This opens up the possibility of having future rake tasks or seeds.rb reuse this same importer code.

eduqg commented 4 years ago

Good solution. But before I merge, I've runned the test and I checked there is some messages like 'Objetivo não criado' (that is) a failure message, can you take a look at this?

nathandonato commented 4 years ago

Sure, I will look into this today.

nathandonato commented 4 years ago

@eduqg I fixed the issue.