-
-
Notifications
You must be signed in to change notification settings - Fork 527
/
Copy pathitems.rb
49 lines (45 loc) · 1.48 KB
/
items.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# == Schema Information
#
# Table name: items
#
# id :integer not null, primary key
# active :boolean default(TRUE)
# barcode_count :integer
# category :string
# distribution_quantity :integer
# name :string
# on_hand_minimum_quantity :integer default(0), not null
# on_hand_recommended_quantity :integer
# package_size :integer
# partner_key :string
# value_in_cents :integer default(0)
# visible_to_partners :boolean default(TRUE), not null
# created_at :datetime not null
# updated_at :datetime not null
# item_category_id :integer
# kit_id :integer
# organization_id :integer
#
FactoryBot.define do
factory :item do
sequence(:name) { |n| "#{n}T Diapers" }
organization { Organization.try(:first) || create(:organization) }
partner_key { BaseItem.first&.partner_key || create(:base_item).partner_key }
value_in_cents { 0 }
kit { nil }
trait :active do
active { true }
end
trait :inactive do
active { false }
end
trait :with_unit do
transient do
unit { "pack" }
end
after(:create) do |item, evaluator|
create(:item_unit, name: evaluator.unit, item: item)
end
end
end
end