Use min age to participate setting on verification residence form

This commit is contained in:
decabeza
2019-03-11 23:23:27 +01:00
parent 6593bc056a
commit 21c6da3767
3 changed files with 20 additions and 2 deletions

View File

@@ -6,6 +6,10 @@ module VerificationHelper
[t("verification.residence.new.document_type.residence_card"), 3]]
end
def minimum_required_age
(Setting["min_age_to_participate"] || 16).to_i
end
def mask_phone(number)
match = number.match(/\d{3}$/)
"******#{match}"

View File

@@ -67,7 +67,7 @@
<%= f.label t("verification.residence.new.date_of_birth") %>
<%= f.date_select :date_of_birth,
prompt: true,
start_year: 1900, end_year: 16.years.ago.year,
start_year: 1900, end_year: minimum_required_age.years.ago.year,
label: false %>
</div>

View File

@@ -16,12 +16,26 @@ feature "Residence" do
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"
end
scenario "Residence form use min age to participate" do
min_age = (Setting["min_age_to_participate"] = 16).to_i
underage = min_age - 1
user = create(:user)
login_as(user)
visit account_path
click_link "Verify my account"
expect(page).to have_select("residence_date_of_birth_1i",
with_options: [min_age.years.ago.year])
expect(page).not_to have_select("residence_date_of_birth_1i",
with_options: [underage.years.ago.year])
end
scenario "When trying to verify a deregistered account old votes are reassigned" do
erased_user = create(:user, document_number: "12345678Z", document_type: "1", erased_at: Time.current)
vote = create(:vote, voter: erased_user)