mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-06 22:36:07 +00:00
Add numericality validation for FlexiRate
This commit is contained in:
@@ -13,6 +13,10 @@ module Calculator
|
||||
localize_number :preferred_first_item,
|
||||
:preferred_additional_item
|
||||
|
||||
validates :preferred_first_item,
|
||||
:preferred_additional_item,
|
||||
numericality: { message: :calculator_preferred_value_error }
|
||||
|
||||
def self.description
|
||||
I18n.t(:flexible_rate)
|
||||
end
|
||||
|
||||
@@ -12,6 +12,16 @@ describe Calculator::FlexiRate do
|
||||
)
|
||||
end
|
||||
|
||||
it do
|
||||
should validate_numericality_of(:preferred_first_item).
|
||||
with_message("Invalid input. Please use only numbers. For example: 10, 5.5, -20")
|
||||
end
|
||||
|
||||
it do
|
||||
should validate_numericality_of(:preferred_additional_item).
|
||||
with_message("Invalid input. Please use only numbers. For example: 10, 5.5, -20")
|
||||
end
|
||||
|
||||
context 'when nb of items ordered is above preferred max' do
|
||||
let(:quantity) { 4.0 }
|
||||
|
||||
|
||||
Reference in New Issue
Block a user