foodsoft/spec/factories/article.rb

37 lines
1 KiB
Ruby
Raw Normal View History

2017-10-27 23:21:31 +02:00
require 'factory_bot'
2017-10-27 23:21:31 +02:00
FactoryBot.define do
2014-11-21 14:37:56 +01:00
factory :_article do
unit { Faker::Unit.unit }
2017-10-08 12:24:31 +02:00
price { rand(0.1..26.0).round(2) }
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
2019-10-28 09:40:43 +01:00
sequence(:name) { |n| Faker::Lorem.words(number: rand(2..4)).join(' ') + " ##{n}" }
2018-10-13 16:21:37 +02:00
supplier
article_category
2014-11-21 14:37:56 +01:00
end
factory :shared_article, class: SharedArticle do
2019-10-28 09:40:43 +01:00
sequence(:name) { |n| Faker::Lorem.words(number: rand(2..4)).join(' ') + " s##{n}" }
order_number { Faker::Lorem.characters(number: rand(1..12)) }
2018-10-13 16:21:37 +02:00
shared_supplier
end
factory :stock_article, class: StockArticle do
sequence(:name) { |n| Faker::Lorem.words(number: rand(2..4)).join(' ') + " ##{n}" }
unit_quantity { 1 }
supplier
article_category
2014-11-21 14:37:56 +01:00
end
end
factory :article_category do
2019-10-28 09:40:43 +01:00
sequence(:name) { |n| Faker::Lorem.characters(number: rand(2..12)) + " ##{n}" }
end
end