Files
openfoodnetwork/spec/factories/voucher_factory.rb
Gaetan Craig-Riou a2c4c44eea Move Vine voucher to Vouchers::Vine
A Vine voucher is really a specific type of FlatRate voucher but because
a Vine voucher can be used by mutiple enterprise, it can be considered
different enough to warrant it's own class.
It still share a lot of the behaviour of a FlatRate voucher, so to avoid
duplication, all the shared functionality have been moved to a
Vouchers::FlatRatable concern.
2024-11-28 13:35:01 +01:00

24 lines
607 B
Ruby

# frozen_string_literal: true
FactoryBot.define do
factory :voucher, class: Voucher do
code { "new_code" }
enterprise { build(:distributor_enterprise) }
amount { 10 }
end
factory :voucher_flat_rate, parent: :voucher, class: Vouchers::FlatRate do
amount { 15 }
end
factory :voucher_percentage_rate, parent: :voucher, class: Vouchers::PercentageRate do
amount { rand(1..100) }
end
factory :vine_voucher, parent: :voucher, class: Vouchers::Vine do
amount { 20 }
external_voucher_id { SecureRandom.uuid }
external_voucher_set_id { SecureRandom.uuid }
end
end