fb2b4d8a8a
chore: fix api test conventions chore: rubocop -A spec/ chore: more rubocop -A fix failing test rubocop fixes removes helper methods that are in my opinion dead code more rubocop fixes rubocop -a --auto-gen-config
27 lines
731 B
Ruby
27 lines
731 B
Ruby
require 'factory_bot'
|
|
|
|
FactoryBot.define do
|
|
factory :order do
|
|
starts { Time.now }
|
|
supplier { create(:supplier, article_count: (article_count.nil? ? true : article_count)) }
|
|
article_ids { supplier.articles.map(&:id) unless supplier.nil? }
|
|
created_by { create(:user) }
|
|
updated_by { create(:user) }
|
|
|
|
transient do
|
|
article_count { true }
|
|
end
|
|
|
|
# for an order from stock; need to add articles
|
|
factory :stock_order do
|
|
supplier_id { 0 }
|
|
# article_ids needs to be supplied
|
|
end
|
|
|
|
# In the order's after_save callback order articles are created, so
|
|
# until the order is saved, these articles do not yet exist.
|
|
after :create do |order|
|
|
order.reload
|
|
end
|
|
end
|
|
end
|