makes age errors visible

This commit is contained in:
kikito
2017-02-07 16:48:19 +01:00
parent 7abb741fc6
commit c473f9856f
2 changed files with 4 additions and 4 deletions

View File

@@ -63,7 +63,7 @@ class Officing::Residence
return unless @census_api_response.valid?
unless allowed_age?
errors.add(:date_of_birth, I18n.t('verification.residence.new.error_not_allowed_age'))
errors.add(:year_of_birth, I18n.t('verification.residence.new.error_not_allowed_age'))
end
end

View File

@@ -30,13 +30,13 @@ describe Officing::Residence do
it "should not be valid if user is under allowed age" do
allow_any_instance_of(Officing::Residence).to receive(:date_of_birth).and_return(15.years.ago)
expect(residence).to_not be_valid
expect(residence.errors[:date_of_birth]).to include("You don't have the required age to participate")
expect(residence.errors[:year_of_birth]).to include("You don't have the required age to participate")
end
it "should be valid if user is above allowed age" do
allow_any_instance_of(Officing::Residence).to receive(:date_of_birth).and_return(16.years.ago)
expect(residence).to be_valid
expect(residence.errors[:date_of_birth]).to be_empty
expect(residence.errors[:year_of_birth]).to be_empty
end
end
@@ -94,4 +94,4 @@ describe Officing::Residence do
end
end
end
end