aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlban Peignier2017-11-26 11:55:24 +0100
committerAlban Peignier2017-11-26 11:55:24 +0100
commit92ce645ed75831f69602f19c6f7cd923408ff170 (patch)
tree03f1e5ce8a1bb4760ae40b31c3e3c0aa21fc2111
parent84ec338abe9fe09caed3edc62784235963463311 (diff)
downloadchouette-core-92ce645ed75831f69602f19c6f7cd923408ff170.tar.bz2
Uses (sorted) .rb files found in db/seeds (instead of db/seeds.rb content). Refs #5074
-rw-r--r--db/seeds.rb40
1 files changed, 4 insertions, 36 deletions
diff --git a/db/seeds.rb b/db/seeds.rb
index d31a35cfc..1cbdb584d 100644
--- a/db/seeds.rb
+++ b/db/seeds.rb
@@ -1,38 +1,6 @@
-# coding: utf-8
-# This file should contain all the record creation needed to seed the database with its default values.
-# The data can then be loaded with the rake db:seed (or created alongside the db with db:setup).
+path = File.join(File.expand_path('../seeds', __FILE__), "*.rb")
-stop_area_referential = StopAreaReferential.find_or_create_by!(name: "Reflex")
-line_referential = LineReferential.find_or_create_by!(name: "CodifLigne")
-
-# Organisations
-stif = Organisation.find_or_create_by!(code: "STIF") do |org|
- org.name = 'STIF'
-end
-operator = Organisation.find_or_create_by!(code: 'transporteur-a') do |organisation|
- organisation.name = "Transporteur A"
+Dir.glob(path).sort.each do |file|
+ puts "Seed #{file}"
+ load file
end
-
-# Member
-line_referential.add_member stif, owner: true
-line_referential.add_member operator
-
-stop_area_referential.add_member stif, owner: true
-stop_area_referential.add_member operator
-
-# Users
-stif.users.find_or_create_by!(username: "admin") do |user|
- user.email = 'stif-boiv@af83.com'
- user.password = "secret"
- user.name = "STIF Administrateur"
-end
-
-operator.users.find_or_create_by!(username: "transporteur") do |user|
- user.email = 'stif-boiv+transporteur@af83.com'
- user.password = "secret"
- user.name = "Martin Lejeune"
-end
-
-# Include all Lines in organisation functional_scope
-stif.update sso_attributes: { functional_scope: line_referential.lines.pluck(:objectid) }
-operator.update sso_attributes: { functional_scope: line_referential.lines.limit(3).pluck(:objectid) }