aboutsummaryrefslogtreecommitdiffstats
path: root/db/seeds/chouette.seeds.rb
diff options
context:
space:
mode:
authorcedricnjanga2017-11-27 14:57:58 +0100
committercedricnjanga2017-11-27 14:57:58 +0100
commitd832ccaa091595bbab0ee0e4c5e863905963686c (patch)
treec696b71c0290a1f28eda7b7b737987289a785a29 /db/seeds/chouette.seeds.rb
parent9b2edfbf417bb5ee8e6e76d881a4fc6e20b0eda2 (diff)
parent77abde1626e317b5017b2ff15b7a9def759b7701 (diff)
downloadchouette-core-d832ccaa091595bbab0ee0e4c5e863905963686c.tar.bz2
Merge branch '4941-refactoring_object_id'
Diffstat (limited to 'db/seeds/chouette.seeds.rb')
-rw-r--r--db/seeds/chouette.seeds.rb38
1 files changed, 38 insertions, 0 deletions
diff --git a/db/seeds/chouette.seeds.rb b/db/seeds/chouette.seeds.rb
new file mode 100644
index 000000000..6adafa3e9
--- /dev/null
+++ b/db/seeds/chouette.seeds.rb
@@ -0,0 +1,38 @@
+# 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).
+
+stop_area_referential = StopAreaReferential.find_or_create_by!(name: "Reflex", objectid_format: "netex")
+line_referential = LineReferential.find_or_create_by!(name: "CodifLigne", objectid_format: "netex")
+
+# 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"
+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) }