From 3133e90d2b59829fa7c78eb435638d17c0820332 Mon Sep 17 00:00:00 2001 From: Robert Sullivan Date: Fri, 15 Mar 2024 17:01:15 +0000 Subject: [PATCH] CLDC-2213: Review markups --- app/services/bulk_upload/sales/year2024/row_parser.rb | 2 +- config/locales/en.yml | 1 - .../bulk_upload/sales/year2024/row_parser_spec.rb | 10 +++++++++- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/app/services/bulk_upload/sales/year2024/row_parser.rb b/app/services/bulk_upload/sales/year2024/row_parser.rb index 53a88a638..9bc91f505 100644 --- a/app/services/bulk_upload/sales/year2024/row_parser.rb +++ b/app/services/bulk_upload/sales/year2024/row_parser.rb @@ -376,7 +376,7 @@ class BulkUpload::Sales::Year2024::RowParser validates :field_116, numericality: { - message: I18n.t("validations.range", question: "Percentage discount", min: "0%", max: "70%"), + message: I18n.t("validations.numeric.within_range", field: "Percentage discount", min: "0%", max: "70%"), greater_than_or_equal_to: 0, less_than_or_equal_to: 70, if: :discounted_ownership?, diff --git a/config/locales/en.yml b/config/locales/en.yml index fdd34ccff..8612e0367 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -211,7 +211,6 @@ en: already_added: "You have already added this managing agent" merged: "That organisation has already been merged. Select a different organisation." not_answered: "You must answer %{question}" - range: "%{question} should be between %{min} and %{max}" invalid_option: "Enter a valid value for %{question}" invalid_number: "Enter a number for %{question}" no_address_found: "We could not find this address. Edit the address data or fix this error on the CORE site." diff --git a/spec/services/bulk_upload/sales/year2024/row_parser_spec.rb b/spec/services/bulk_upload/sales/year2024/row_parser_spec.rb index f75c62463..c62f2f1f9 100644 --- a/spec/services/bulk_upload/sales/year2024/row_parser_spec.rb +++ b/spec/services/bulk_upload/sales/year2024/row_parser_spec.rb @@ -730,7 +730,7 @@ RSpec.describe BulkUpload::Sales::Year2024::RowParser do let(:attributes) { valid_attributes.merge({ field_8: "2", field_116: "71" }) } it "returns correct error" do - expect(parser.errors.where(:field_116).map(&:message)).to include("Percentage discount should be between 0% and 70%") + expect(parser.errors.where(:field_116).map(&:message)).to include("Percentage discount must be between 0% and 70%") end end @@ -741,6 +741,14 @@ RSpec.describe BulkUpload::Sales::Year2024::RowParser do expect(parser.errors.where(:field_116)).not_to be_present end end + + context "when percentage less than 0" do + let(:attributes) { valid_attributes.merge({ field_8: "2", field_116: "-1" }) } + + it "returns correct error" do + expect(parser.errors.where(:field_116).map(&:message)).to include("Percentage discount must be between 0% and 70%") + end + end end describe "#field_11" do # type for outright sale