mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-27 01:43:22 +00:00
Remove voucher validation on code format
The code doesn't rely on label match any more so this restriction is not necessary anymore
This commit is contained in:
@@ -13,9 +13,6 @@ class Voucher < ApplicationRecord
|
||||
dependent: :nullify
|
||||
|
||||
validates :code, presence: true, uniqueness: { scope: :enterprise_id }
|
||||
# We store the tax portion of a voucher in a separate adjustment with a label starting by "Tax"
|
||||
# when tax are exluded from price. To avoid any issue we a code stating by Tax in not allowed
|
||||
validates :code, format: { without: /\ATax/ }
|
||||
|
||||
TYPES = ["Vouchers::FlatRate", "Vouchers::PercentageRate"].freeze
|
||||
|
||||
|
||||
@@ -117,10 +117,6 @@ en:
|
||||
using_producer_stock_settings_but_count_on_hand_set: "must be blank because using producer stock settings"
|
||||
on_demand_but_count_on_hand_set: "must be blank if on demand"
|
||||
limited_stock_but_no_count_on_hand: "must be specified because forcing limited stock"
|
||||
voucher:
|
||||
attributes:
|
||||
code:
|
||||
invalid: "can't start with 'Tax'"
|
||||
messages:
|
||||
confirmation: "doesn't match %{attribute}"
|
||||
blank: "can't be blank"
|
||||
|
||||
@@ -28,11 +28,6 @@ describe Voucher do
|
||||
|
||||
it { is_expected.to validate_presence_of(:code) }
|
||||
it { is_expected.to validate_uniqueness_of(:code).scoped_to(:enterprise_id) }
|
||||
it "doesn't accept code starting with 'Tax'" do
|
||||
voucher = build(:voucher_flat_rate, code: 'Taxnew_code', enterprise: enterprise)
|
||||
|
||||
expect(voucher.valid?).to be(false)
|
||||
end
|
||||
end
|
||||
|
||||
describe '#display_value' do
|
||||
|
||||
Reference in New Issue
Block a user