solidus icon indicating copy to clipboard operation
solidus copied to clipboard

Ensure db:seed runs before spree_sample:load

Open lsizani opened this issue 3 years ago • 4 comments

Summary

When running bundle exec rake spree_sample:load against an empty database, an exception is raised in db/samples/tax_rates.rb on account of missing a Spree::Zone with the name "North America.

In this PR we:

  • Add db:seed as a dependent task of spree_sample:load
  • Check that Spree::Zone "North America" is present in db/samples/tax_rates.rb before running the rest of the seed file. This makes it consistent with db/samples/shipping_methods.rb

Checklist

Check out our PR guidelines for more details.

The following are mandatory for all PRs:

The following are not always needed:

  • 📖 ~~I have updated the README to account for my changes.~~
  • 📑 I have documented new code with YARD.
  • 🛣️ I have opened a PR to update the guides.
  • ✅ I have added automated tests to cover my changes.
  • 📸 I have attached screenshots to demo visual changes.

lsizani avatar Feb 06 '23 15:02 lsizani

Thanks! I left a comment. Also, I'm curious about what happens if db:seed and sample:load are run independently, one after the other. Is db:seed executed twice in that case?

It will run db:seed twice in that case. I checked on this and I can confirm that the current seeds can be run multiple times without raising errors or duplicating data.

lsizani avatar Feb 07 '23 11:02 lsizani

@lsizani do you know if we have any spec that verify we can run seeds multiple times without breaking or creating duplicate records?

kennyadsl avatar Feb 08 '23 08:02 kennyadsl

@lsizani do you know if we have any spec that verify we can run seeds multiple times without breaking or creating duplicate records?

We do not... But I'm sure I can write one

lsizani avatar Feb 08 '23 09:02 lsizani

Hey @lsizani! I lost track of this PR, I didn't notice you updated it following my suggestions. I will re-review it now, in the meantime there are some conflict with the main branch to address, if you have time for a rebase. Thanks again!

kennyadsl avatar Jun 13 '23 12:06 kennyadsl