From 91fcb7c7c40b2a5312545181bc6e35b858385556 Mon Sep 17 00:00:00 2001 From: luisramos0 Date: Fri, 14 Jun 2019 12:12:45 +0100 Subject: [PATCH] Extract enterprises factories to separate file --- spec/factories.rb | 35 --------------------------- spec/factories/enterprise_factory.rb | 36 ++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+), 35 deletions(-) create mode 100644 spec/factories/enterprise_factory.rb diff --git a/spec/factories.rb b/spec/factories.rb index 5fa9a03e84..9bf1daef5a 100644 --- a/spec/factories.rb +++ b/spec/factories.rb @@ -65,36 +65,6 @@ FactoryBot.define do visible true end - factory :enterprise, :class => Enterprise do - owner { FactoryBot.create :user } - sequence(:name) { |n| "Enterprise #{n}" } - sells 'any' - description 'enterprise' - long_description '

Hello, world!

This is a paragraph.

' - address { FactoryBot.create(:address) } - end - - factory :supplier_enterprise, :parent => :enterprise do - is_primary_producer true - sells "none" - end - - factory :distributor_enterprise, :parent => :enterprise do - is_primary_producer false - sells "any" - - transient do - with_payment_and_shipping false - end - - after(:create) do |enterprise, proxy| - if proxy.with_payment_and_shipping - create(:payment_method, distributors: [enterprise]) - create(:shipping_method, distributors: [enterprise]) - end - end - end - factory :enterprise_relationship do end @@ -258,11 +228,6 @@ FactoryBot.define do end end - factory :distributor_enterprise_with_tax, parent: :distributor_enterprise do - charges_sales_tax { true } - allow_order_changes { true } - end - factory :completed_order_with_fees, parent: :order_with_distributor do transient do payment_fee 5 diff --git a/spec/factories/enterprise_factory.rb b/spec/factories/enterprise_factory.rb new file mode 100644 index 0000000000..0cdfe8c82c --- /dev/null +++ b/spec/factories/enterprise_factory.rb @@ -0,0 +1,36 @@ +FactoryBot.define do + factory :enterprise, :class => Enterprise do + owner { FactoryBot.create :user } + sequence(:name) { |n| "Enterprise #{n}" } + sells 'any' + description 'enterprise' + long_description '

Hello, world!

This is a paragraph.

' + address { FactoryBot.create(:address) } + end + + factory :supplier_enterprise, :parent => :enterprise do + is_primary_producer true + sells "none" + end + + factory :distributor_enterprise, :parent => :enterprise do + is_primary_producer false + sells "any" + + transient do + with_payment_and_shipping false + end + + after(:create) do |enterprise, proxy| + if proxy.with_payment_and_shipping + create(:payment_method, distributors: [enterprise]) + create(:shipping_method, distributors: [enterprise]) + end + end + end + + factory :distributor_enterprise_with_tax, parent: :distributor_enterprise do + charges_sales_tax { true } + allow_order_changes { true } + end +end \ No newline at end of file