Make WebSection seeds idempotent

Each time we were loading the seeds file, more web sections were
created.

On production it meant running `db:seeds` several times created the
records even if they already existed.

During the test, it meant 5 more records were created before every test,
so after ending a test run, thousands of records existed, making banner
tests very slow.
This commit is contained in:
Javi Martín
2019-07-09 21:41:53 +02:00
parent ce112860f9
commit c3bcb10c2b

View File

@@ -9,11 +9,11 @@ end
Setting.reset_defaults
WebSection.create(name: "homepage")
WebSection.create(name: "debates")
WebSection.create(name: "proposals")
WebSection.create(name: "budgets")
WebSection.create(name: "help_page")
WebSection.where(name: "homepage").first_or_create
WebSection.where(name: "debates").first_or_create
WebSection.where(name: "proposals").first_or_create
WebSection.where(name: "budgets").first_or_create
WebSection.where(name: "help_page").first_or_create
# Default custom pages
load Rails.root.join("db", "pages.rb")