2017-10-27 23:21:31 +02:00
|
|
|
require 'factory_bot'
|
2013-07-14 02:49:40 +02:00
|
|
|
|
2017-10-27 23:21:31 +02:00
|
|
|
FactoryBot.define do
|
2013-07-14 02:49:40 +02:00
|
|
|
|
2014-11-21 14:37:56 +01:00
|
|
|
factory :_article do
|
2013-07-14 02:49:40 +02:00
|
|
|
unit { Faker::Unit.unit }
|
2017-10-08 12:24:31 +02:00
|
|
|
price { rand(0.1..26.0).round(2) }
|
2013-07-14 02:49:40 +02:00
|
|
|
tax { [6, 21].sample }
|
|
|
|
deposit { rand(10) < 8 ? 0 : [0.0, 0.80, 1.20, 12.00].sample }
|
|
|
|
unit_quantity { rand(5) < 3 ? 1 : rand(1..20) }
|
2014-11-21 14:37:56 +01:00
|
|
|
|
|
|
|
factory :article do
|
|
|
|
sequence(:name) { |n| Faker::Lorem.words(rand(2..4)).join(' ') + " ##{n}" }
|
|
|
|
supplier { create :supplier }
|
|
|
|
article_category { create :article_category }
|
|
|
|
end
|
|
|
|
|
|
|
|
factory :shared_article, class: SharedArticle do
|
|
|
|
sequence(:name) { |n| Faker::Lorem.words(rand(2..4)).join(' ') + " s##{n}" }
|
|
|
|
order_number { Faker::Lorem.characters(rand(1..12)) }
|
|
|
|
supplier { create :shared_supplier }
|
|
|
|
end
|
2013-07-14 02:49:40 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
factory :article_category do
|
2013-07-25 00:52:41 +02:00
|
|
|
sequence(:name) { |n| Faker::Lorem.characters(rand(2..12)) + " ##{n}" }
|
2013-07-14 02:49:40 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
end
|