Add new fields to form

- Add :date_of_birth and :postal_code
- Only display new fields when aplication has configured the Remote
  Census API and contains values for fields. Check with Setting Class
  methods:
  - force_presence_date_of_birth?
  - force_presence_postal_code?
This commit is contained in:
taitus
2019-05-14 12:34:25 +02:00
committed by Javi Martín
parent bc36c5a987
commit ceaf118188
3 changed files with 84 additions and 13 deletions

View File

@@ -33,24 +33,79 @@ describe "DocumentVerifications" do
expect(user.reload).to be_level_three_verified
end
scenario "Verifying a user which does not exist and is not in the census shows an error" do
describe "Verifying througth Census" do
expect_any_instance_of(Verification::Management::Document).to receive(:in_census?).and_return(false)
context "Census API" do
visit management_document_verifications_path
fill_in "document_verification_document_number", with: "inexisting"
click_button "Check document"
scenario "Verifying a user which does not exist and is not in the census shows an error" do
expect(page).to have_content "This document is not registered"
end
expect_any_instance_of(Verification::Management::Document).to receive(:in_census?).
and_return(false)
scenario "Verifying a user which does exists in the census but not in the db redirects allows sending an email" do
visit management_document_verifications_path
fill_in "document_verification_document_number", with: "inexisting"
click_button "Check document"
visit management_document_verifications_path
fill_in "document_verification_document_number", with: "12345678Z"
click_button "Check document"
expect(page).to have_content "This document is not registered"
end
scenario "Verifying a user which does exists in the census but not in the db redirects allows sending an email" do
visit management_document_verifications_path
fill_in "document_verification_document_number", with: "12345678Z"
click_button "Check document"
expect(page).to have_content "Please introduce the email used on the account"
end
end
context "Remote Census API" do
before do
Setting["feature.remote_census"] = true
Setting["remote_census.request.date_of_birth"] = "some.value"
Setting["remote_census.request.postal_code"] = "some.value"
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
end
after do
Setting["feature.remote_census"] = nil
Setting["remote_census.request.date_of_birth"] = nil
Setting["remote_census.request.postal_code"] = nil
end
scenario "Verifying a user which does not exist and is not in the census shows an error" do
expect_any_instance_of(Verification::Management::Document).to receive(:in_census?).
and_return(false)
visit management_document_verifications_path
fill_in "document_verification_document_number", with: "12345678Z"
select_date "31-December-1980", from: "document_verification_date_of_birth"
fill_in "document_verification_postal_code", with: "inexisting"
click_button "Check document"
expect(page).to have_content "This document is not registered"
end
scenario "Verifying a user which does exists in the census but not in the db redirects allows sending an email" do
visit management_document_verifications_path
fill_in "document_verification_document_number", with: "12345678Z"
select_date "31-December-1980", from: "document_verification_date_of_birth"
fill_in "document_verification_postal_code", with: "28013"
click_button "Check document"
expect(page).to have_content "Please introduce the email used on the account"
end
end
expect(page).to have_content "Please introduce the email used on the account"
end
scenario "Document number is format-standarized" do