improve test setup with factory bot

This commit is contained in:
João Geonizeli
2021-08-14 11:58:51 -03:00
parent 51a493b327
commit 97c6f28b03
10 changed files with 176 additions and 16 deletions

View File

@@ -0,0 +1,30 @@
# frozen_string_literal: true
# == Schema Information
#
# Table name: balances
#
# id :bigint not null, primary key
# amount :decimal(20, 10) default(0.0), not null
# created_at :datetime not null
# updated_at :datetime not null
# currency_id :bigint not null
# user_id :bigint not null
#
# Indexes
#
# index_balances_on_currency_id (currency_id)
# index_balances_on_user_id (user_id)
#
# Foreign Keys
#
# fk_rails_... (currency_id => currencies.id)
# fk_rails_... (user_id => users.id)
#
FactoryBot.define do
factory :balance do
association :user
association :currency
amount { (rand * (10000 - 0) + 0) }
end
end