improve seeds for the users and add clients

This commit is contained in:
Felix Van der Jeugt 2015-09-14 16:50:47 +02:00
parent 32e1ebfb94
commit a88f94ba3a
2 changed files with 7 additions and 2 deletions

View file

@ -5,7 +5,12 @@ unless Rails.env.production?
users = FactoryGirl.create_list(:user, 20) users = FactoryGirl.create_list(:user, 20)
100.times do 100.times do
sample_users = users.sample(2) sample_users = users.sample(2)
FactoryGirl.create :transaction, debtor: sample_users[0], creditor: sample_users[1], amount: 1 + rand(100) FactoryGirl.create :transaction, debtor: sample_users[0], creditor: sample_users[1]
end
clients = FactoryGirl.create_list(:client, 5)
100.times do
debtor, creditor = users.sample(2)
FactoryGirl.create :client_transaction, issuer: clients.sample, debtor: debtor, creditor: creditor
end end
end end
end end

View file

@ -19,7 +19,7 @@ FactoryGirl.define do
association :debtor, factory: :user association :debtor, factory: :user
association :creditor, factory: :user association :creditor, factory: :user
issuer { debtor } issuer { debtor }
amount { 1 + rand(100) } amount { 1 + rand(10000) }
message { Faker::Lorem.sentence } message { Faker::Lorem.sentence }
factory :client_transaction do factory :client_transaction do
association :issuer, factory: :client association :issuer, factory: :client