Browse Source

fix validation

pull/1633/head
Phil Lee 3 years ago
parent
commit
d9141d2f23
  1. 4
      app/services/bulk_upload/sales/year2022/row_parser.rb
  2. 10
      spec/services/bulk_upload/sales/year2022/row_parser_spec.rb

4
app/services/bulk_upload/sales/year2022/row_parser.rb

@ -966,9 +966,9 @@ private
if setup_question?(question)
fields.each do |field|
if errors[field].blank?
if errors[field].none?
block_log_creation!
errors.add(field, I18n.t("validations.invalid_option", question: QUESTIONS[field]), category: :setup)
errors.add(field, I18n.t("validations.invalid_option", question: QUESTIONS[field].downcase), category: :setup)
end
end
else

10
spec/services/bulk_upload/sales/year2022/row_parser_spec.rb

@ -451,6 +451,16 @@ RSpec.describe BulkUpload::Sales::Year2022::RowParser do
end
end
describe "#field_113" do # purchase made thru ownership scheme?
context "when an invalid option" do
let(:attributes) { setup_section_params.merge({ field_113: "100" }) }
it "returns setup error" do
expect(parser.errors.where(:field_113, category: :setup).map(&:message)).to eql(["Enter a valid value for was this purchase made through an ownership scheme?"])
end
end
end
describe "#field_117" do
context "when not a possible value" do
let(:attributes) { valid_attributes.merge({ field_117: "3" }) }

Loading…
Cancel
Save