@ -126,4 +126,36 @@ RSpec.describe Validations::Sales::FinancialValidations do
expect ( record . errors [ " stairowned " ] ) . to include ( match I18n . t ( " validations.financial.staircasing.percentage_bought_must_be_greater_than_percentage_owned " ) )
end
end
describe " # validate_percentage_owned_not_too_much_if_older_person " do
let ( :record ) { FactoryBot . create ( :sales_log ) }
context " when log type is not older persons shared ownership " do
it " does not add an error when percentage owned after staircasing transaction exceeds 75% " do
record . type = 2
record . stairowned = 80
financial_validator . validate_percentage_owned_not_too_much_if_older_person ( record )
expect ( record . errors [ " stairowned " ] ) . to be_empty
expect ( record . errors [ " type " ] ) . to be_empty
end
end
context " when log type is older persons shared ownership " do
it " does not add an error when percentage owned after staircasing transaction is less than 75% " do
record . type = 24
record . stairowned = 50
financial_validator . validate_percentage_owned_not_too_much_if_older_person ( record )
expect ( record . errors [ " stairowned " ] ) . to be_empty
expect ( record . errors [ " type " ] ) . to be_empty
end
it " adds an error when percentage owned after staircasing transaction exceeds 75% " do
record . type = 24
record . stairowned = 90
financial_validator . validate_percentage_owned_not_too_much_if_older_person ( record )
expect ( record . errors [ " stairowned " ] ) . to include ( match I18n . t ( " validations.financial.staircasing.older_person_percentage_owned_maximum_75 " ) )
expect ( record . errors [ " type " ] ) . to include ( match I18n . t ( " validations.financial.staircasing.older_person_percentage_owned_maximum_75 " ) )
end
end
end
end