Skip to content

Commit

Permalink
Merge pull request #1504 from Ivanov-Anton/YETI-WEB-rename-factories-…
Browse files Browse the repository at this point in the history
…to-be-annotated

rename file name of factories to be annotated by annotate gem
  • Loading branch information
dmitry-sinina committed Jul 16, 2024
2 parents 87303ef + e616803 commit 3a9fcd1
Show file tree
Hide file tree
Showing 199 changed files with 4,396 additions and 1,885 deletions.
2 changes: 1 addition & 1 deletion spec/factories/account_balance_notification_settings.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,6 @@
# fk_rails_f185d22f87 (account_id => accounts.id)
#
FactoryBot.define do
factory :account_balance_notification_setting do
factory :account_balance_notification_setting, class: 'AccountBalanceNotificationSetting' do
end
end
40 changes: 39 additions & 1 deletion spec/factories/account.rb → spec/factories/accounts.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,45 @@
# frozen_string_literal: true

# == Schema Information
#
# Table name: billing.accounts
#
# id :integer(4) not null, primary key
# balance :decimal(, ) not null
# destination_rate_limit :decimal(, )
# invoice_ref_template :string default("$id"), not null
# max_balance :decimal(, ) not null
# max_call_duration :integer(4)
# min_balance :decimal(, ) not null
# name :string not null
# next_invoice_at :timestamptz
# origination_capacity :integer(2)
# send_invoices_to :integer(4) is an Array
# termination_capacity :integer(2)
# total_capacity :integer(2)
# uuid :uuid not null
# vat :decimal(, ) default(0.0), not null
# contractor_id :integer(4) not null
# external_id :bigint(8)
# invoice_period_id :integer(2)
# invoice_template_id :integer(4)
# next_invoice_type_id :integer(2)
# timezone_id :integer(4) default(1), not null
#
# Indexes
#
# accounts_contractor_id_idx (contractor_id)
# accounts_external_id_key (external_id) UNIQUE
# accounts_name_key (name) UNIQUE
# accounts_uuid_key (uuid) UNIQUE
#
# Foreign Keys
#
# accounts_contractor_id_fkey (contractor_id => contractors.id)
# accounts_timezone_id_fkey (timezone_id => timezones.id)
#
FactoryBot.define do
factory :account, class: Account do
factory :account, class: 'Account' do
sequence(:name) { |n| "account#{n}" }
association :contractor, vendor: true
balance { 0 }
Expand Down
2 changes: 1 addition & 1 deletion spec/factories/active_calls.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# frozen_string_literal: true

FactoryBot.define do
factory :active_call, class: RealtimeData::ActiveCall do
factory :active_call, class: 'RealtimeData::ActiveCall' do
trait :filled do
duration { (rand(60) + rand).round(7) }
start_time { rand(120..179).seconds.ago.to_f }
Expand Down
19 changes: 0 additions & 19 deletions spec/factories/admin_user.rb

This file was deleted.

50 changes: 50 additions & 0 deletions spec/factories/admin_users.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# frozen_string_literal: true

# == Schema Information
#
# Table name: admin_users
#
# id :integer(4) not null, primary key
# allowed_ips :inet is an Array
# current_sign_in_at :timestamptz
# current_sign_in_ip :string(255)
# enabled :boolean default(TRUE)
# encrypted_password :string(255) default(""), not null
# last_sign_in_at :timestamptz
# last_sign_in_ip :string(255)
# per_page :json not null
# remember_created_at :timestamptz
# reset_password_sent_at :timestamptz
# reset_password_token :string(255)
# roles :string not null, is an Array
# saved_filters :json not null
# sign_in_count :integer(4) default(0)
# stateful_filters :boolean default(FALSE), not null
# username :string not null
# visible_columns :json not null
# created_at :timestamptz not null
# updated_at :timestamptz not null
#
# Indexes
#
# admin_users_username_idx (username) UNIQUE
# admin_users_username_key (username) UNIQUE
# index_admin_users_on_reset_password_token (reset_password_token) UNIQUE
#
FactoryBot.define do
factory :admin_user, class: 'AdminUser' do
sequence(:username) { |n| "admin#{n}" }
sequence(:email) { |n| "admin#{n}@example.com" }
password { '111111' }
roles { ['user'] }
after(:build) do |admin|
if admin.class.ldap?
admin.encrypted_password = admin.encrypt_password(admin.password)
end
end

trait :filled do
association :billing_contact, factory: :contact
end
end
end
2 changes: 1 addition & 1 deletion spec/factories/api_access.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
# api_access_customer_id_fkey (customer_id => contractors.id)

FactoryBot.define do
factory :api_access, class: System::ApiAccess do
factory :api_access, class: 'System::ApiAccess' do
sequence(:login) { |n| "api_access-#{n}" }
password { ('a'..'z').to_a.shuffle.join }
allowed_ips { ['0.0.0.0', '127.0.0.1'] }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,24 @@
#
# Table name: versions
#
# id :integer not null, primary key
# item_type :string(255) not null
# item_id :integer not null
# id :integer(4) not null, primary key
# event :string(255) not null
# whodunnit :string(255)
# object :text
# created_at :datetime
# ip :string(255)
# item_type :string(255) not null
# object :text
# object_changes :text
# txid :integer
# txid :bigint(8)
# whodunnit :string(255)
# created_at :timestamptz
# item_id :bigint(8) not null
#
# Indexes
#
# index_versions_on_item_type_and_item_id (item_type,item_id)
#

FactoryBot.define do
factory :audit_log_item, class: AuditLogItem do
factory :audit_log_item, class: 'AuditLogItem' do
item_type { 'Account' }
association :item, factory: :account
event { 'update' }
Expand Down
40 changes: 0 additions & 40 deletions spec/factories/auth_log.rb

This file was deleted.

32 changes: 32 additions & 0 deletions spec/factories/background_tasks.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# frozen_string_literal: true

# == Schema Information
#
# Table name: delayed_jobs
#
# id :integer(4) not null, primary key
# attempts :integer(4) default(0), not null
# failed_at :timestamptz
# handler :text not null
# last_error :text
# locked_at :timestamptz
# locked_by :string(255)
# priority :integer(4) default(0), not null
# queue :string(255)
# run_at :timestamptz
# unique_name :string
# created_at :timestamptz not null
# updated_at :timestamptz not null
#
# Indexes
#
# delayed_jobs_priority (priority,run_at)
#

FactoryBot.define do
factory :background_task, class: 'BackgroundTask' do
priority { 0 }
attempts { 0 }
handler { "--- !ruby/object:ActiveJob::QueueAdapters::DelayedJobAdapter::JobWrapper\njob_data:\n job_class: Worker::CdrExportJob\n job_id: 71b02934-f68e-4a98-a90c-de8d274a37ed\n provider_job_id: \n queue_name: cdr_export\n priority: \n arguments:\n - 1\n executions: 0\n locale: en\n" }
end
end
Empty file.
14 changes: 0 additions & 14 deletions spec/factories/billing/contact.rb

This file was deleted.

35 changes: 35 additions & 0 deletions spec/factories/billing/contacts.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# frozen_string_literal: true

# == Schema Information
#
# Table name: notifications.contacts
#
# id :integer(4) not null, primary key
# email :string not null
# notes :string
# created_at :timestamptz
# updated_at :timestamptz
# admin_user_id :integer(4)
# contractor_id :integer(4)
#
# Indexes
#
# contacts_contractor_id_idx (contractor_id)
#
# Foreign Keys
#
# contacts_admin_user_id_fkey (admin_user_id => admin_users.id)
# contacts_contractor_id_fkey (contractor_id => contractors.id)
#
FactoryBot.define do
factory :contact, class: 'Billing::Contact' do
sequence(:email) { |n| "rspec_mail_#{n}@example.com" }

association :contractor, factory: :customer

trait :filled do
association :contractor, factory: :customer
admin_user { build(:admin_user, :filled) }
end
end
end
2 changes: 1 addition & 1 deletion spec/factories/billing/invoice_documents.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
#

FactoryBot.define do
factory :invoice_document, class: Billing::InvoiceDocument do
factory :invoice_document, class: 'Billing::InvoiceDocument' do
invoice
filename { 'fine.example' }

Expand Down
2 changes: 1 addition & 1 deletion spec/factories/billing/invoice_originated_destinations.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
#

FactoryBot.define do
factory :invoice_originated_destination, class: Billing::InvoiceOriginatedDestination do
factory :invoice_originated_destination, class: 'Billing::InvoiceOriginatedDestination' do
invoice { FactoryBot.create(:invoice, :manual, account: FactoryBot.create(:account)) }

trait :filled do
Expand Down
2 changes: 1 addition & 1 deletion spec/factories/billing/invoice_originated_networks.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
#

FactoryBot.define do
factory :invoice_originated_network, class: Billing::InvoiceOriginatedNetwork do
factory :invoice_originated_network, class: 'Billing::InvoiceOriginatedNetwork' do
invoice { FactoryBot.create(:invoice, :manual, account: FactoryBot.create(:account)) }

trait :filled do
Expand Down
2 changes: 1 addition & 1 deletion spec/factories/billing/invoice_service_data.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
# invoice_service_data_invoice_id_fkey (invoice_id => invoices.id)
#
FactoryBot.define do
factory :invoice_service_data, class: Billing::InvoiceServiceData do
factory :invoice_service_data, class: 'Billing::InvoiceServiceData' do
invoice { FactoryBot.create(:invoice, :manual, account: FactoryBot.create(:account)) }
transactions_count { 1 }
amount { 0.01 }
Expand Down
8 changes: 0 additions & 8 deletions spec/factories/billing/invoice_template.rb

This file was deleted.

23 changes: 23 additions & 0 deletions spec/factories/billing/invoice_templates.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# frozen_string_literal: true

# == Schema Information
#
# Table name: invoice_templates
#
# id :integer(4) not null, primary key
# data :binary
# filename :string not null
# name :string not null
# sha1 :string
# created_at :timestamptz
#
# Indexes
#
# invoices_templates_name_key (name) UNIQUE
#
FactoryBot.define do
factory :invoice_template, class: 'Billing::InvoiceTemplate' do
sequence(:name) { |n| "invoice_template#{n}" }
filename { 'filename.odt' }
end
end
2 changes: 1 addition & 1 deletion spec/factories/billing/invoice_terminated_destinations.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
#

FactoryBot.define do
factory :invoice_terminated_destination, class: Billing::InvoiceTerminatedDestination do
factory :invoice_terminated_destination, class: 'Billing::InvoiceTerminatedDestination' do
invoice { FactoryBot.create(:invoice, :manual, account: FactoryBot.create(:account)) }

trait :filled do
Expand Down
2 changes: 1 addition & 1 deletion spec/factories/billing/invoice_terminated_networks.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
#

FactoryBot.define do
factory :invoice_terminated_network, class: Billing::InvoiceTerminatedNetwork do
factory :invoice_terminated_network, class: 'Billing::InvoiceTerminatedNetwork' do
invoice { FactoryBot.create(:invoice, :manual, account: FactoryBot.create(:account)) }

trait :filled do
Expand Down
2 changes: 1 addition & 1 deletion spec/factories/billing/invoices.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
# index_billing.invoices_on_reference (reference)
#
FactoryBot.define do
factory :invoice, class: Billing::Invoice do
factory :invoice, class: 'Billing::Invoice' do
start_date { 7.days.ago.utc }
end_date { 1.day.ago.utc }
state_id { Billing::InvoiceState::NEW }
Expand Down
Loading

0 comments on commit 3a9fcd1

Please sign in to comment.