validates voter in census
This commit is contained in:
@@ -74,7 +74,7 @@ class CensusApi
|
||||
if end_point_available?
|
||||
client.call(:get_habita_datos, message: request(document_type, document_number)).body
|
||||
else
|
||||
stubbed_response_body
|
||||
stubbed_response(document_type, document_number)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -97,8 +97,20 @@ class CensusApi
|
||||
Rails.env.staging? || Rails.env.preproduction? || Rails.env.production?
|
||||
end
|
||||
|
||||
def stubbed_response_body
|
||||
{get_habita_datos_response: {get_habita_datos_return: {hay_errores: false, datos_habitante: { item: {fecha_nacimiento_string: "31-12-1980", identificador_documento: "12345678Z", descripcion_sexo: "Varón" }}, datos_vivienda: {item: {codigo_postal: "28013", codigo_distrito: "01"}}}}}
|
||||
def stubbed_response(document_type, document_number)
|
||||
if document_number == "12345678Z" && document_type == "1"
|
||||
stubbed_valid_response
|
||||
else
|
||||
stubbed_invalid_response
|
||||
end
|
||||
end
|
||||
|
||||
def stubbed_valid_response
|
||||
{get_habita_datos_response: {get_habita_datos_return: {datos_habitante: { item: {fecha_nacimiento_string: "31-12-1980", identificador_documento: "12345678Z", descripcion_sexo: "Varón" }}, datos_vivienda: {item: {codigo_postal: "28013", codigo_distrito: "01"}}}}}
|
||||
end
|
||||
|
||||
def stubbed_invalid_response
|
||||
{get_habita_datos_response: {get_habita_datos_return: {datos_habitante: {}, datos_vivienda: {}}}}
|
||||
end
|
||||
|
||||
def is_dni?(document_type)
|
||||
|
||||
Reference in New Issue
Block a user