foodsoft/spec/factories/article.rb

30 lines
859 B
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
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
end
factory :article_category do
2013-07-25 00:52:41 +02:00
sequence(:name) { |n| Faker::Lorem.characters(rand(2..12)) + " ##{n}" }
end
end