diff --git a/app/models/verification/residence.rb b/app/models/verification/residence.rb index a8c20adfd..c69538dde 100644 --- a/app/models/verification/residence.rb +++ b/app/models/verification/residence.rb @@ -71,7 +71,7 @@ class Verification::Residence private def retrieve_census_data - @census_data = CensusCaller.new.call(document_type, document_number) + @census_data = CensusCaller.new.call(document_type, document_number, date_of_birth, postal_code) end def residency_valid? diff --git a/spec/features/verification/residence_spec.rb b/spec/features/verification/residence_spec.rb index cd05b4545..bf02abb91 100644 --- a/spec/features/verification/residence_spec.rb +++ b/spec/features/verification/residence_spec.rb @@ -21,6 +21,31 @@ describe "Residence" do expect(page).to have_content "Residence verified" end + scenario "Verify resident throught RemoteCensusApi" do + Setting["feature.remote_census"] = true + + access_user_data = "get_habita_datos_response.get_habita_datos_return.datos_habitante.item" + access_residence_data = "get_habita_datos_response.get_habita_datos_return.datos_vivienda.item" + Setting["remote_census.response.date_of_birth"] = "#{access_user_data}.fecha_nacimiento_string" + Setting["remote_census.response.postal_code"] = "#{access_residence_data}.codigo_postal" + Setting["remote_census.response.valid"] = access_user_data + user = create(:user) + login_as(user) + + visit account_path + click_link "Verify my account" + + fill_in "residence_document_number", with: "12345678Z" + select "DNI", from: "residence_document_type" + select_date "31-December-1980", from: "residence_date_of_birth" + fill_in "residence_postal_code", with: "28013" + check "residence_terms_of_service" + click_button "Verify residence" + + expect(page).to have_content "Residence verified" + Setting["feature.remote_census"] = nil + end + scenario "Residence form use min age to participate" do min_age = (Setting["min_age_to_participate"] = 16).to_i underage = min_age - 1