Skip to content

Instantly share code, notes, and snippets.

@axsuul
Created August 8, 2012 19:29
Show Gist options
  • Save axsuul/3297898 to your computer and use it in GitHub Desktop.
Save axsuul/3297898 to your computer and use it in GitHub Desktop.
FactoryGirl.define do
factory :neutral_account, class: FinancialAccounting::Update::Neutral::Account do
load_sequence { FactoryGirl.generate(:sn) }
loaded_at { Time.now }
recorded_at { Time.now }
created_at { Time.now }
updated_at { Time.now }
factory :valid_neutral_account do
association :custodian, factory: :custodian
association :advisory_firm, factory: :advisory_firm
#association :account, factory: :account, strategy: :build
account_number { Faker::Financial.random_string(9) }
account_identifier { "#{Platform::Custodian.find(custodian).code}-#{account_number}" }
advisory_firm_number { Faker::Financial.random_string(3) }
advisory_firm_identifier { Platform::AdvisoryFirmIdentifier.lookup_advisory_firm_identifier(custodian_id, advisory_firm_number) }
date_opened { Time.now }
end
factory :valid_neutral_account_with_production_record, parent: :valid_neutral_account do
association :account, factory: :account
after(:create) do |account|
FactoryGirl.modify do
factory :account, class: FinancialAccounting::Account do
account_identifier { account.account_identifier # TRYING TO RELATE THIS TO THE account_identifier generated above }
account_number { account.account_number }
end
end
end
end
end
factory :invalid_neutral_account, class: FinancialAccounting::Update::Neutral::Account do
load_sequence nil
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment