mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-03 22:06:07 +00:00
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.
24 lines
607 B
Ruby
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
|