Browse Source

CLDC-2213: Review markups

pull/2316/head
Robert Sullivan 2 years ago
parent
commit
3133e90d2b
  1. 2
      app/services/bulk_upload/sales/year2024/row_parser.rb
  2. 1
      config/locales/en.yml
  3. 10
      spec/services/bulk_upload/sales/year2024/row_parser_spec.rb

2
app/services/bulk_upload/sales/year2024/row_parser.rb

@ -376,7 +376,7 @@ class BulkUpload::Sales::Year2024::RowParser
validates :field_116, validates :field_116,
numericality: { 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, greater_than_or_equal_to: 0,
less_than_or_equal_to: 70, less_than_or_equal_to: 70,
if: :discounted_ownership?, if: :discounted_ownership?,

1
config/locales/en.yml

@ -211,7 +211,6 @@ en:
already_added: "You have already added this managing agent" already_added: "You have already added this managing agent"
merged: "That organisation has already been merged. Select a different organisation." merged: "That organisation has already been merged. Select a different organisation."
not_answered: "You must answer %{question}" not_answered: "You must answer %{question}"
range: "%{question} should be between %{min} and %{max}"
invalid_option: "Enter a valid value for %{question}" invalid_option: "Enter a valid value for %{question}"
invalid_number: "Enter a number 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." no_address_found: "We could not find this address. Edit the address data or fix this error on the CORE site."

10
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" }) } let(:attributes) { valid_attributes.merge({ field_8: "2", field_116: "71" }) }
it "returns correct error" do 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
end end
@ -741,6 +741,14 @@ RSpec.describe BulkUpload::Sales::Year2024::RowParser do
expect(parser.errors.where(:field_116)).not_to be_present expect(parser.errors.where(:field_116)).not_to be_present
end end
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 end
describe "#field_11" do # type for outright sale describe "#field_11" do # type for outright sale

Loading…
Cancel
Save