mirror of
https://github.com/internetee/registry.git
synced 2025-05-16 17:37:17 +02:00
parent
b1bf725e27
commit
72d0c74b0f
1 changed files with 72 additions and 18 deletions
|
@ -10,8 +10,37 @@ namespace :dev do
|
||||||
FactoryGirl.find_definitions
|
FactoryGirl.find_definitions
|
||||||
|
|
||||||
PaperTrail.enabled = false
|
PaperTrail.enabled = false
|
||||||
|
Domain.paper_trail_on!
|
||||||
|
Contact.paper_trail_on!
|
||||||
|
|
||||||
with_random_data = args[:random].present?
|
with_random_data = args[:random].present?
|
||||||
|
|
||||||
|
def create_domain(name:, registrar:, registrant:, account:, price:, reg_time:)
|
||||||
|
duration = price.duration.sub('mons', 'months').split("\s")
|
||||||
|
period = duration.first.to_i
|
||||||
|
period_unit = duration.second[0]
|
||||||
|
|
||||||
|
create(:domain,
|
||||||
|
name: name,
|
||||||
|
period: period,
|
||||||
|
period_unit: period_unit,
|
||||||
|
registered_at: reg_time,
|
||||||
|
valid_from: reg_time,
|
||||||
|
expire_time: reg_time + period.send(duration.second.to_sym),
|
||||||
|
created_at: reg_time,
|
||||||
|
updated_at: reg_time,
|
||||||
|
registrar: registrar,
|
||||||
|
registrant: registrant)
|
||||||
|
|
||||||
|
create(:account_activity,
|
||||||
|
account: account,
|
||||||
|
sum: -price.price.amount,
|
||||||
|
activity_type: AccountActivity::CREATE,
|
||||||
|
created_at: reg_time,
|
||||||
|
updated_at: reg_time,
|
||||||
|
price: price)
|
||||||
|
end
|
||||||
|
|
||||||
def generate_default_data
|
def generate_default_data
|
||||||
create(:admin_user, username: 'test', password: 'testtest', password_confirmation: 'testtest')
|
create(:admin_user, username: 'test', password: 'testtest', password_confirmation: 'testtest')
|
||||||
|
|
||||||
|
@ -19,29 +48,54 @@ namespace :dev do
|
||||||
registrar = create(:registrar, name: 'test')
|
registrar = create(:registrar, name: 'test')
|
||||||
registrant = create(:registrant, name: 'test', registrar: registrar)
|
registrant = create(:registrant, name: 'test', registrar: registrar)
|
||||||
|
|
||||||
create(:account, registrar: registrar, balance: 1_000_000)
|
account = create(:account, registrar: registrar, balance: 1_000_000)
|
||||||
create(:api_user, username: 'test', password: 'testtest', registrar: registrar)
|
api_user = create(:api_user, username: 'test', password: 'testtest', registrar: registrar)
|
||||||
create(:domain,
|
|
||||||
name: 'test.test',
|
epp_session = build(:epp_session, registrar: registrar)
|
||||||
period: 1,
|
epp_session[:api_user_id] = api_user.id
|
||||||
period_unit: 'y',
|
epp_session.registrar_id = registrar.id
|
||||||
registered_at: Time.zone.now,
|
epp_session.save!
|
||||||
valid_from: Time.zone.now,
|
|
||||||
expire_time: Time.zone.now + 10.years,
|
domain_counter = 1.step
|
||||||
registrar: registrar,
|
|
||||||
registrant: registrant)
|
|
||||||
|
|
||||||
Billing::Price.durations.each do |duration|
|
Billing::Price.durations.each do |duration|
|
||||||
Billing::Price.operation_categories.each do |operation_category|
|
Billing::Price.operation_categories.each do |operation_category|
|
||||||
create(:price,
|
price = create(:price,
|
||||||
price: Money.from_amount(1),
|
price: Money.from_amount(duration.to_i * 10),
|
||||||
valid_from: Time.zone.now.beginning_of_day,
|
valid_from: Time.zone.now - rand(1).months,
|
||||||
valid_to: Time.zone.now + 10.years,
|
valid_to: Time.zone.now + rand(1).months,
|
||||||
duration: duration,
|
duration: duration,
|
||||||
operation_category: operation_category,
|
operation_category: operation_category,
|
||||||
zone: zone)
|
zone: zone)
|
||||||
|
|
||||||
|
next if operation_category == 'renew'
|
||||||
|
|
||||||
|
(rand(3) + 1).times do
|
||||||
|
create_domain(name: "test#{domain_counter.next}.test",
|
||||||
|
registrar: registrar,
|
||||||
|
registrant: registrant,
|
||||||
|
account: account,
|
||||||
|
price: price,
|
||||||
|
reg_time: 1.month.ago)
|
||||||
|
end
|
||||||
|
|
||||||
|
(rand(3) + 1).times do
|
||||||
|
create_domain(name: "test#{domain_counter.next}.test",
|
||||||
|
registrar: registrar,
|
||||||
|
registrant: registrant,
|
||||||
|
account: account,
|
||||||
|
price: price,
|
||||||
|
reg_time: Time.zone.now)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
create_domain(name: 'test.test',
|
||||||
|
registrar: registrar,
|
||||||
|
registrant: registrant,
|
||||||
|
account: account,
|
||||||
|
price: Billing::Price.first,
|
||||||
|
reg_time: Time.zone.now)
|
||||||
end
|
end
|
||||||
|
|
||||||
def generate_random_data
|
def generate_random_data
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue