@ -198,7 +198,7 @@ RSpec.describe BulkUpload::Sales::Year2022::RowParser do
it " has errors on correct setup fields " do
errors = parser . errors . select { | e | e . options [ :category ] == :setup } . map ( & :attribute )
expect ( errors ) . to eql ( % i [ field_2 field_3 field_4 field_113 field_92 ] )
expect ( errors ) . to eql ( % i [ field_2 field_3 field_4 field_113 field_92 field_112 ] )
end
end
@ -214,7 +214,7 @@ RSpec.describe BulkUpload::Sales::Year2022::RowParser do
it " has errors on correct setup fields " do
errors = parser . errors . select { | e | e . options [ :category ] == :setup } . map ( & :attribute )
expect ( errors ) . to eql ( % i [ field_2 field_3 field_4 field_57 field_116 field_92 ] )
expect ( errors ) . to eql ( % i [ field_2 field_3 field_4 field_57 field_116 field_92 field_112 ] )
end
end
@ -232,7 +232,7 @@ RSpec.describe BulkUpload::Sales::Year2022::RowParser do
it " has errors on correct setup fields " do
errors = parser . errors . select { | e | e . options [ :category ] == :setup } . map ( & :attribute )
expect ( errors ) . to eql ( % i [ field_2 field_3 field_4 field_109 field_92 ] )
expect ( errors ) . to eql ( % i [ field_2 field_3 field_4 field_109 field_92 field_112 ] )
end
end
@ -248,7 +248,7 @@ RSpec.describe BulkUpload::Sales::Year2022::RowParser do
it " has errors on correct setup fields " do
errors = parser . errors . select { | e | e . options [ :category ] == :setup } . map ( & :attribute )
expect ( errors ) . to eql ( % i [ field_2 field_3 field_4 field_76 field_116 field_92 ] )
expect ( errors ) . to eql ( % i [ field_2 field_3 field_4 field_76 field_116 field_92 field_112 ] )
end
end
@ -266,7 +266,7 @@ RSpec.describe BulkUpload::Sales::Year2022::RowParser do
it " has errors on correct setup fields " do
errors = parser . errors . select { | e | e . options [ :category ] == :setup } . map ( & :attribute )
expect ( errors ) . to eql ( % i [ field_2 field_3 field_4 field_109 field_92 ] )
expect ( errors ) . to eql ( % i [ field_2 field_3 field_4 field_109 field_92 field_112 ] )
end
end
@ -280,9 +280,10 @@ RSpec.describe BulkUpload::Sales::Year2022::RowParser do
end
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_84 field_115 field_114 field_92 ] )
expect ( errors ) . to eql ( % i [ field_2 field_3 field_4 field_84 field_114 field_92 field_112 ] )
end
end
@ -291,22 +292,23 @@ RSpec.describe BulkUpload::Sales::Year2022::RowParser do
{
bulk_upload : ,
field_1 : " test id " ,
field_113 : " 3 " ,
field_84 : " 12 " ,
field_85 : " other sale type " ,
field_113 : " 3 " ,
field_114 : " 2 " ,
}
end
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_115 field_116 field_92 ] )
expect ( errors ) . to eql ( % i [ field_2 field_3 field_4 field_115 field_116 field_92 field_112 ] . sort )
end
end
describe " # field_57 " do # type of shared ownership scheme
context " when an invalid option " do
let ( :attributes ) { setup_section_params . merge ( { field_57 : " 100 " } ) }
let ( :attributes ) { setup_section_params . merge ( field_57 : " 100 " , field_113 : " 1 " ) }
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? " ] )
@ -314,6 +316,36 @@ RSpec.describe BulkUpload::Sales::Year2022::RowParser do
end
end
describe " # field_76 " do # type of discounted ownership scheme
context " when an invalid option " do
let ( :attributes ) { setup_section_params . merge ( { field_76 : " 100 " , field_113 : " 2 " } ) }
it " returns setup error " do
expect ( parser . errors . where ( :field_76 , category : :setup ) . map ( & :message ) ) . to eql ( [ " Enter a valid value for what is the type of discounted ownership sale? " ] )
end
end
end
describe " # field_84 " do # type of outright sale
context " when an invalid option " do
let ( :attributes ) { setup_section_params . merge ( { field_84 : " 100 " , field_113 : " 3 " } ) }
it " returns setup error " do
expect ( parser . errors . where ( :field_84 , category : :setup ) . map ( & :message ) ) . to eql ( [ " Enter a valid value for what is the type of outright sale? " ] )
end
end
end
describe " # field_85 " do # type of other outright sale
context " when cant be blank " do
let ( :attributes ) { setup_section_params . merge ( { field_85 : nil , field_84 : " 12 " } ) }
it " returns setup error " do
expect ( parser . errors . where ( :field_85 , category : :setup ) . map ( & :message ) ) . to eql ( [ " You must answer type of outright sale " ] )
end
end
end
describe " # field_92 " do # owning org
context " when no data given " do
let ( :attributes ) { { bulk_upload : , field_92 : " " } }
@ -461,6 +493,26 @@ RSpec.describe BulkUpload::Sales::Year2022::RowParser do
end
end
describe " # field_109 " do # more that 2 joint purchasers?
context " when an invalid option " do
let ( :attributes ) { setup_section_params . merge ( { field_109 : " 100 " , field_116 : " 1 " } ) }
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? " ] )
end
end
end
describe " # field_112 " do # data protection
context " when not accepted " do
let ( :attributes ) { setup_section_params . merge ( field_112 : nil ) }
it " returns setup error " do
expect ( parser . errors . where ( :field_112 , category : :setup ) . map ( & :message ) ) . to eql ( [ " You must answer data protection question " ] )
end
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 " } ) }
@ -471,6 +523,36 @@ RSpec.describe BulkUpload::Sales::Year2022::RowParser do
end
end
describe " # field_114 " do # is buyer a company?
context " when an invalid option " do
let ( :attributes ) { setup_section_params . merge ( { field_114 : " 100 " , field_113 : " 3 " } ) }
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? " ] )
end
end
end
describe " # field_115 " do # will buyers live in property?
context " when an invalid option " do
let ( :attributes ) { setup_section_params . merge ( { field_115 : " 100 " , field_113 : " 3 " , field_114 : " 2 " } ) }
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? " ] )
end
end
end
describe " # field_116 " do # joint purchase?
context " when an invalid option " do
let ( :attributes ) { setup_section_params . merge ( { field_116 : " 100 " } ) }
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? " ] )
end
end
end
describe " # field_117 " do
context " when not a possible value " do
let ( :attributes ) { valid_attributes . merge ( { field_117 : " 3 " } ) }