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:
@@ -34,7 +34,8 @@ class Management::DocumentVerificationsController < Management::BaseController
|
|||||||
private
|
private
|
||||||
|
|
||||||
def document_verification_params
|
def document_verification_params
|
||||||
params.require(:document_verification).permit(:document_type, :document_number)
|
params.require(:document_verification).permit(:document_type, :document_number,
|
||||||
|
:date_of_birth, :postal_code)
|
||||||
end
|
end
|
||||||
|
|
||||||
def set_document
|
def set_document
|
||||||
|
|||||||
@@ -18,6 +18,21 @@
|
|||||||
label: t("management.document_number")
|
label: t("management.document_number")
|
||||||
%>
|
%>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<% if Setting.force_presence_date_of_birth? %>
|
||||||
|
<div class="date-of-birth small-12 medium-5">
|
||||||
|
<%= f.date_select :date_of_birth,
|
||||||
|
prompt: true,
|
||||||
|
start_year: 1900, end_year: minimum_required_age.years.ago.year %>
|
||||||
|
</div>
|
||||||
|
<% end %>
|
||||||
|
|
||||||
|
<% if Setting.force_presence_postal_code? %>
|
||||||
|
<div class="small-12 medium-5">
|
||||||
|
<%= f.text_field :postal_code, aria: {describedby: "postal-code-help-text"} %>
|
||||||
|
</div>
|
||||||
|
<% end %>
|
||||||
|
|
||||||
<%= f.submit t("management.check"), class: "button" %>
|
<%= f.submit t("management.check"), class: "button" %>
|
||||||
<% end %>
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -33,9 +33,14 @@ describe "DocumentVerifications" do
|
|||||||
expect(user.reload).to be_level_three_verified
|
expect(user.reload).to be_level_three_verified
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe "Verifying througth Census" do
|
||||||
|
|
||||||
|
context "Census API" do
|
||||||
|
|
||||||
scenario "Verifying a user which does not exist and is not in the census shows an error" do
|
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)
|
expect_any_instance_of(Verification::Management::Document).to receive(:in_census?).
|
||||||
|
and_return(false)
|
||||||
|
|
||||||
visit management_document_verifications_path
|
visit management_document_verifications_path
|
||||||
fill_in "document_verification_document_number", with: "inexisting"
|
fill_in "document_verification_document_number", with: "inexisting"
|
||||||
@@ -53,6 +58,56 @@ describe "DocumentVerifications" do
|
|||||||
expect(page).to have_content "Please introduce the email used on the account"
|
expect(page).to have_content "Please introduce the email used on the account"
|
||||||
end
|
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
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
scenario "Document number is format-standarized" do
|
scenario "Document number is format-standarized" do
|
||||||
|
|
||||||
visit management_document_verifications_path
|
visit management_document_verifications_path
|
||||||
|
|||||||
Reference in New Issue
Block a user