From 8387fa5c441025bec890c440571dc5dbe8c154d0 Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Mon, 10 Apr 2017 20:03:21 +0300 Subject: [PATCH 1/3] Simplify seeds.rb #460 --- db/seeds.rb | 147 ++++++++++++++-------------------------------------- 1 file changed, 39 insertions(+), 108 deletions(-) diff --git a/db/seeds.rb b/db/seeds.rb index ac6da0598..5aef9cb21 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -1,116 +1,47 @@ # 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). -registrar1 = Registrar.where( - name: 'Registrar First AS', - reg_no: '10300220', - street: 'Pärnu mnt 2', - city: 'Tallinn', - state: 'Harju maakond', - zip: '11415', - email: 'registrar1@example.com', - country_code: 'EE', - code: 'REG1' -).first_or_create! +ActiveRecord::Base.transaction do + registrar = Registrar.create!( + name: 'Test', + reg_no: '1234', + street: 'test', + city: 'test', + state: 'test', + zip: '1234', + email: 'test@test.com', + country_code: 'US', + code: 'US1' + ) -@api_user1 = ApiUser.where( - username: 'registrar1', -).first_or_create!( - password: 'password', - identity_code: '51001091072', - active: true, - registrar: registrar1, - roles: ['super'] -) + registrar.accounts.create!(account_type: Account::CASH, currency: 'EUR') + ApiUser.create!( + username: 'test', + password: 'testtest', + identity_code: '51001091072', + active: true, + registrar: registrar, + roles: ['super'] + ) -registrar2 = Registrar.where( - name: 'Registrar Second AS', - reg_no: '10529229', - street: 'Vabaduse pst 32', - city: 'Tallinn', - state: 'Harju maakond', - zip: '11315', - email: 'registrar2@example.com', - country_code: 'EE', - code: 'REG2' -).first_or_create! + AdminUser.create!( + username: 'test', + email: 'test@test.com', + password: 'testtest', + password_confirmation: 'testtest', + country_code: 'US', + roles: ['admin'] + ) -@api_user2 = ApiUser.where( - username: 'registrar2', -).first_or_create!( - password: 'password', - identity_code: '11412090004', - active: true, - registrar: registrar2, - roles: ['super'] -) - - -Registrar.all.each do |x| - x.accounts.where(account_type: Account::CASH, currency: 'EUR').first_or_create! + ZonefileSetting.create!( + origin: 'com', + ttl: 43200, + refresh: 3600, + retry: 900, + expire: 1209600, + minimum_ttl: 3600, + email: 'example.com', + master_nameserver: 'example.com' + ) end - -admin1 = { - username: 'user1', - email: 'user1@example.ee', - identity_code: '37810013855', - country_code: 'EE' -} -admin2 = { - username: 'user2', - email: 'user2@example.ee', - identity_code: '37810010085', - country_code: 'EE' -} -admin3 = { - username: 'user3', - email: 'user3@example.ee', - identity_code: '37810010727', - country_code: 'EE' -} - -[admin1, admin2, admin3].each do |at| - admin = AdminUser.where(at) - next if admin.present? - admin = AdminUser.new(at.merge({ password_confirmation: 'testtest', password: 'testtest' })) - admin.roles = ['admin'] - admin.save -end - -ZonefileSetting.where({ - origin: 'ee', - ttl: 43200, - refresh: 3600, - retry: 900, - expire: 1209600, - minimum_ttl: 3600, - email: 'hostmaster.eestiinternet.ee', - master_nameserver: 'ns.tld.ee' -}).first_or_create! - -ZonefileSetting.where({ - origin: 'pri.ee', - ttl: 43200, - refresh: 3600, - retry: 900, - expire: 1209600, - minimum_ttl: 3600, - email: 'hostmaster.eestiinternet.ee', - master_nameserver: 'ns.tld.ee' -}).first_or_create! - -# Registrar.where( -# name: 'EIS', -# reg_no: '90010019', -# phone: '+3727271000', -# country_code: 'EE', -# vat_no: 'EE101286464', -# email: 'info@internet.ee', -# state: 'Harjumaa', -# city: 'Tallinn', -# street: 'Paldiski mnt 80', -# zip: '10617', -# url: 'www.internet.ee', -# code: 'EIS' -# ).first_or_create! From 4ff84f19939fa3c4775e6dd5438ba10583d81eb6 Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Tue, 11 Apr 2017 09:57:09 +0300 Subject: [PATCH 2/3] Fix seeds.rb #460 --- db/seeds.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/db/seeds.rb b/db/seeds.rb index 5aef9cb21..8a3896047 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -35,13 +35,13 @@ ActiveRecord::Base.transaction do ) ZonefileSetting.create!( - origin: 'com', + origin: 'tld', ttl: 43200, refresh: 3600, retry: 900, expire: 1209600, minimum_ttl: 3600, - email: 'example.com', - master_nameserver: 'example.com' + email: 'admin.domain.tld', + master_nameserver: 'ns.tld' ) end From b2ab59bb7d3558a23eb9d2ee3096de9a90103895 Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Wed, 12 Apr 2017 14:35:19 +0300 Subject: [PATCH 3/3] Fix seeds.rb --- db/seeds.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/db/seeds.rb b/db/seeds.rb index 8a3896047..0ed61cba6 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -9,7 +9,7 @@ ActiveRecord::Base.transaction do city: 'test', state: 'test', zip: '1234', - email: 'test@test.com', + email: 'test@domain.tld', country_code: 'US', code: 'US1' ) @@ -27,7 +27,7 @@ ActiveRecord::Base.transaction do AdminUser.create!( username: 'test', - email: 'test@test.com', + email: 'test@domain.tld', password: 'testtest', password_confirmation: 'testtest', country_code: 'US',