aboutsummaryrefslogtreecommitdiffstats
path: root/db/seeds.rb
diff options
context:
space:
mode:
authorRobertDober2017-04-10 11:03:11 +0200
committerRobertDober2017-04-11 15:40:26 +0200
commit7b9370d10a2d67b83610b8cf8b876734972c2ee9 (patch)
tree37f7767c2efa2dc596e5668be1165fd20fb8925b /db/seeds.rb
parentb19578172fc0d8ddc3d9ec8fa325854a8eebbe69 (diff)
downloadchouette-core-7b9370d10a2d67b83610b8cf8b876734972c2ee9.tar.bz2
Deprecation Warnings removed; Seeds corrected, Refs: #2070
Diffstat (limited to 'db/seeds.rb')
-rw-r--r--db/seeds.rb41
1 files changed, 21 insertions, 20 deletions
diff --git a/db/seeds.rb b/db/seeds.rb
index 7526330ed..815327300 100644
--- a/db/seeds.rb
+++ b/db/seeds.rb
@@ -7,25 +7,9 @@
# cities = City.create([{ :name => 'Chicago' }, { :name => 'Copenhagen' }])
# Mayor.create(:name => 'Emanuel', :city => cities.first)
-
-stop_area_referential = StopAreaReferential.find_or_create_by(name: "Reflex")
-line_referential = LineReferential.find_or_create_by(name: "CodifLigne")
-
stif = Organisation.find_or_create_by!(name: "STIF") do |org|
org.code = 'STIF'
end
-operator = Organisation.find_or_create_by!(code: 'transporteur-a') do |organisation|
- organisation.name = "Transporteur A"
-end
-
-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
-
-line_referential.save
-stop_area_referential.save
stif.users.find_or_create_by!(username: "admin") do |user|
user.email = 'stif-boiv@af83.com'
@@ -33,18 +17,33 @@ stif.users.find_or_create_by!(username: "admin") do |user|
user.name = "STIF Administrateur"
end
+
+operator = Organisation.find_or_create_by!(code: 'transporteur-a') do |organisation|
+ organisation.name = "Transporteur A"
+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
+stop_area_referential = StopAreaReferential.find_or_create_by!(name: "Reflex") do |referential|
+ referential.add_member stif, owner: true
+ referential.add_member operator
+end
+
10.times do |n|
- stop_area_referential.stop_areas.find_or_create_by name: "Test #{n}", area_type: "Quay", objectid: "StopArea: #{n}"
+ stop_area_referential.stop_areas.find_or_create_by! name: "Test #{n}", area_type: "zdep", objectid: "StopArea: #{n}"
+end
+
+line_referential = LineReferential.find_or_create_by!(name: "CodifLigne") do |referential|
+ referential.add_member stif, owner: true
+ referential.add_member operator
end
-LineReferentialSync.find_or_create_by(line_referential: line_referential)
-StopAreaReferentialSync.find_or_create_by(stop_area_referential: stop_area_referential)
+LineReferentialSync.find_or_create_by!(line_referential: line_referential)
+StopAreaReferentialSync.find_or_create_by!(stop_area_referential: stop_area_referential)
10.times do |n|
line_referential.lines.find_or_create_by name: "Test #{n}" do |l|
@@ -56,9 +55,11 @@ workbench = Workbench.find_by(name: "Gestion de l'offre")
[["parissudest201604", "Paris Sud-Est Avril 2016"],
["parissudest201605", "Paris Sud-Est Mai 2016"]].each do |slug, name|
- operator.referentials.find_or_create_by!(slug: slug) do |referential|
+ operator.referentials.find_or_create_by(slug: slug) do |referential|
referential.name = name
referential.prefix = slug
referential.workbench = workbench
+ referential.line_referential = line_referential
+ referential.stop_area_referential = stop_area_referential
end
end