Files
openfoodnetwork/spec/factories/payment_method_factory.rb
Gaetan Craig-Riou d95aac333b Add internal to payment method
It's used to hide the payment method used for paying with credit. These
payment method are for internal use only.
2026-03-10 16:07:42 +11:00

41 lines
1.4 KiB
Ruby

# frozen_string_literal: true
FactoryBot.define do
factory :payment_method, class: Spree::PaymentMethod::Check do
name { 'Check' }
environment { 'test' }
distributors { [Enterprise.is_distributor.first || FactoryBot.create(:distributor_enterprise)] }
trait :flat_rate do
transient { amount { 1 } }
calculator { build(:calculator_flat_rate, preferred_amount: amount) }
end
trait :per_item do
transient { amount { 1 } }
calculator { build(:calculator_per_item, preferred_amount: amount) }
end
end
factory :stripe_sca_payment_method, class: Spree::Gateway::StripeSCA do
name { 'StripeSCA' }
environment { 'test' }
distributors { [FactoryBot.create(:stripe_account).enterprise] }
preferred_enterprise_id { distributors.first.id }
end
factory :distributor_payment_method, class: DistributorPaymentMethod do
distributor { FactoryBot.create(:distributor_enterprise) }
payment_method { FactoryBot.create(:payment_method) }
end
factory :customer_credit_payment_method, class: Spree::PaymentMethod::CustomerCredit do
name { Rails.application.config.credit_payment_method[:name] }
description { Rails.application.config.credit_payment_method[:description] }
environment { 'test' }
internal { true }
distributors { [Enterprise.is_distributor.first || FactoryBot.create(:distributor_enterprise)] }
end
end