Files
grecia/db/seeds.rb
Javi Martín c3bcb10c2b 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.
2019-08-06 22:00:29 +02:00

20 lines
734 B
Ruby

# coding: utf-8
# Default admin user (change password after first deploy to a server!)
if Administrator.count == 0 && !Rails.env.test?
admin = User.create!(username: "admin", email: "admin@consul.dev", password: "12345678",
password_confirmation: "12345678", confirmed_at: Time.current,
terms_of_service: "1")
admin.create_administrator
end
Setting.reset_defaults
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")