Browse Source

fix rebase issues

pull/1633/head
Phil Lee 3 years ago
parent
commit
52c7912296
  1. 3
      app/services/bulk_upload/sales/year2022/row_parser.rb
  2. 27
      spec/services/bulk_upload/sales/year2022/row_parser_spec.rb

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

@ -277,6 +277,7 @@ class BulkUpload::Sales::Year2022::RowParser
validates :field_57, validates :field_57,
presence: { presence: {
message: I18n.t("validations.not_answered", question: "shared ownership type"), message: I18n.t("validations.not_answered", question: "shared ownership type"),
category: :setup,
}, },
if: :shared_ownership?, if: :shared_ownership?,
on: :after_log on: :after_log
@ -293,6 +294,7 @@ class BulkUpload::Sales::Year2022::RowParser
validates :field_76, validates :field_76,
presence: { presence: {
message: I18n.t("validations.not_answered", question: "discounted ownership type"), message: I18n.t("validations.not_answered", question: "discounted ownership type"),
category: :setup,
}, },
if: :discounted_ownership?, if: :discounted_ownership?,
on: :after_log on: :after_log
@ -309,6 +311,7 @@ class BulkUpload::Sales::Year2022::RowParser
validates :field_84, validates :field_84,
presence: { presence: {
message: I18n.t("validations.not_answered", question: "type of outright sale"), message: I18n.t("validations.not_answered", question: "type of outright sale"),
category: :setup,
}, },
if: :outright_sale?, if: :outright_sale?,
on: :after_log on: :after_log

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

@ -212,9 +212,9 @@ RSpec.describe BulkUpload::Sales::Year2022::RowParser do
end end
it "has errors on correct setup fields" do it "has errors on correct setup fields" do
errors = parser.errors.select { |e| e.options[:category] == :setup }.map(&:attribute) errors = parser.errors.select { |e| e.options[:category] == :setup }.map(&:attribute).sort
expect(errors).to eql(%i[field_2 field_3 field_4 field_57 field_116 field_92 field_112]) expect(errors).to eql(%i[field_112 field_116 field_2 field_3 field_4 field_57 field_92])
end end
end end
@ -246,9 +246,9 @@ RSpec.describe BulkUpload::Sales::Year2022::RowParser do
end end
it "has errors on correct setup fields" do it "has errors on correct setup fields" do
errors = parser.errors.select { |e| e.options[:category] == :setup }.map(&:attribute) errors = parser.errors.select { |e| e.options[:category] == :setup }.map(&:attribute).sort
expect(errors).to eql(%i[field_2 field_3 field_4 field_76 field_116 field_92 field_112]) expect(errors).to eql(%i[field_112 field_116 field_2 field_3 field_4 field_76 field_92])
end end
end end
@ -282,8 +282,7 @@ RSpec.describe BulkUpload::Sales::Year2022::RowParser do
it "has errors on correct setup fields" do it "has errors on correct setup fields" do
errors = parser.errors.select { |e| e.options[:category] == :setup }.map(&:attribute).sort errors = parser.errors.select { |e| e.options[:category] == :setup }.map(&:attribute).sort
expect(errors).to eql(%i[field_2 field_3 field_4 field_84 field_115 field_114 field_92]) expect(errors).to eql(%i[field_112 field_114 field_115 field_2 field_3 field_4 field_84 field_92])
expect(errors).to eql(%i[field_2 field_3 field_4 field_84 field_114 field_92 field_112])
end end
end end
@ -311,7 +310,7 @@ RSpec.describe BulkUpload::Sales::Year2022::RowParser do
let(:attributes) { setup_section_params.merge(field_57: "100", field_113: "1") } let(:attributes) { setup_section_params.merge(field_57: "100", field_113: "1") }
it "returns setup error" do it "returns setup error" do
expect(parser.errors.where(:field_57, category: :setup).map(&:message)).to eql(["Enter a valid value for what is the type of shared ownership sale?"]) expect(parser.errors.where(:field_57, category: :setup).map(&:message)).to include("Enter a valid value for what is the type of shared ownership sale?")
end end
end end
end end
@ -498,7 +497,7 @@ RSpec.describe BulkUpload::Sales::Year2022::RowParser do
let(:attributes) { setup_section_params.merge({ field_109: "100", field_116: "1" }) } let(:attributes) { setup_section_params.merge({ field_109: "100", field_116: "1" }) }
it "returns setup error" do it "returns setup error" do
expect(parser.errors.where(:field_109, category: :setup).map(&:message)).to eql(["Enter a valid value for are there more than two joint purchasers of this property?"]) expect(parser.errors.where(:field_109, category: :setup).map(&:message)).to include("Enter a valid value for are there more than two joint purchasers of this property?")
end end
end end
end end
@ -518,7 +517,7 @@ RSpec.describe BulkUpload::Sales::Year2022::RowParser do
let(:attributes) { setup_section_params.merge({ field_113: "100" }) } let(:attributes) { setup_section_params.merge({ field_113: "100" }) }
it "returns setup error" do 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?"]) expect(parser.errors.where(:field_113, category: :setup).map(&:message)).to include("Enter a valid value for was this purchase made through an ownership scheme?")
end end
end end
end end
@ -528,7 +527,7 @@ RSpec.describe BulkUpload::Sales::Year2022::RowParser do
let(:attributes) { setup_section_params.merge({ field_114: "100", field_113: "3" }) } let(:attributes) { setup_section_params.merge({ field_114: "100", field_113: "3" }) }
it "returns setup error" do it "returns setup error" do
expect(parser.errors.where(:field_114, category: :setup).map(&:message)).to eql(["Enter a valid value for is the buyer a company?"]) expect(parser.errors.where(:field_114, category: :setup).map(&:message)).to include("Enter a valid value for is the buyer a company?")
end end
end end
end end
@ -538,7 +537,7 @@ RSpec.describe BulkUpload::Sales::Year2022::RowParser do
let(:attributes) { setup_section_params.merge({ field_115: "100", field_113: "3", field_114: "2" }) } let(:attributes) { setup_section_params.merge({ field_115: "100", field_113: "3", field_114: "2" }) }
it "returns setup error" do it "returns setup error" do
expect(parser.errors.where(:field_115, category: :setup).map(&:message)).to eql(["Enter a valid value for will the buyers live in the property?"]) expect(parser.errors.where(:field_115, category: :setup).map(&:message)).to include("Enter a valid value for will the buyers live in the property?")
end end
end end
end end
@ -548,7 +547,7 @@ RSpec.describe BulkUpload::Sales::Year2022::RowParser do
let(:attributes) { setup_section_params.merge({ field_116: "100" }) } let(:attributes) { setup_section_params.merge({ field_116: "100" }) }
it "returns setup error" do it "returns setup error" do
expect(parser.errors.where(:field_116, category: :setup).map(&:message)).to eql(["Enter a valid value for is this a joint purchase?"]) expect(parser.errors.where(:field_116, category: :setup).map(&:message)).to include("Enter a valid value for is this a joint purchase?")
end end
end end
end end
@ -730,10 +729,6 @@ RSpec.describe BulkUpload::Sales::Year2022::RowParser do
it "is not permitted as a setup error" do it "is not permitted as a setup error" do
expect(parser.errors.where(:field_57, category: :setup)).to be_present expect(parser.errors.where(:field_57, category: :setup)).to be_present
end end
it "blocks log creation" do
expect(parser).to be_block_log_creation
end
end end
end end
end end

Loading…
Cancel
Save