Rails.logger.info("Updating location #{original_attributes['location_code']}, with location_code: #{location_code}")
else
Rails.logger.info("Cannot update location #{original_attributes['location_code']} with #{key}: #{value}. Location admin distrint #{value} is not a valid option")
end
when"postcode"
if!value&.match(POSTCODE_REGEXP)
Rails.logger.info("Cannot update location #{original_attributes['location_code']} with #{key}: #{value}. #{I18n.t('validations.postcode')}")
else
location.postcode=PostcodeService.clean(value)
Rails.logger.info("Updating location #{original_attributes['location_code']}, with postcode: #{value}")
end
when"name","units","type_of_unit","mobility_type"
begin
location[key]=value
Rails.logger.info("Updating location #{original_attributes['location_code']}, with #{key}: #{value}")
rescueArgumentError=>e
Rails.logger.info("Cannot update location #{original_attributes['location_code']} with #{key}: #{value}. #{e.message}")
end
when"scheme_code"
scheme=Scheme.find_by(id:value.delete("S"))
ifscheme.present?
location["scheme_id"]=scheme.id
Rails.logger.info("Updating location #{original_attributes['location_code']}, with scheme: S#{scheme.id}")
else
Rails.logger.info("Cannot update location #{original_attributes['location_code']} with #{key}: #{value}. Scheme with id #{value} is not in the database")
end
when"location_code","status","active_dates"
Rails.logger.info("Cannot update location #{original_attributes['location_code']} with #{key} as it it not a permitted field")
expect(Rails.logger).toreceive(:info).with("Cannot update location #{locations[2].id} with postcode: SWAAA. Enter a postcode in the correct format, for example AA1 1AA")
expect(Rails.logger).toreceive(:info).with("Cannot update location #{locations[2].id} with scheme_code: S. Scheme with id S is not in the database")
expect(Rails.logger).toreceive(:info).with("Cannot update location #{locations[2].id} with location_admin_district: Westminst. Location admin distrint Westminst is not a valid option")
expect(Rails.logger).toreceive(:info).with("Cannot update location #{locations[2].id} with type_of_unit: elf-contained house. 'elf-contained house' is not a valid type_of_unit")
expect(Rails.logger).toreceive(:info).with("Cannot update location #{locations[2].id} with mobility_type: 55. '55' is not a valid mobility_type")
expect(Rails.logger).toreceive(:info).with("Cannot update location #{locations[2].id} with status as it it not a permitted field")