diff --git a/app/models/officing/residence.rb b/app/models/officing/residence.rb index 346cd410d..ca0eee9b9 100644 --- a/app/models/officing/residence.rb +++ b/app/models/officing/residence.rb @@ -35,7 +35,7 @@ class Officing::Residence document_number: document_number, document_type: document_type, geozone: geozone, - date_of_birth: date_of_birth.in_time_zone.to_datetime, + date_of_birth: response_date_of_birth.in_time_zone.to_datetime, gender: gender, residence_verified_at: Time.current, verified_at: Time.current, @@ -86,7 +86,7 @@ class Officing::Residence end def allowed_age? - Age.in_years(date_of_birth) >= User.minimum_required_age + Age.in_years(response_date_of_birth) >= User.minimum_required_age end def geozone @@ -101,7 +101,7 @@ class Officing::Residence @census_api_response.gender end - def date_of_birth + def response_date_of_birth @census_api_response.date_of_birth end diff --git a/spec/models/officing/residence_spec.rb b/spec/models/officing/residence_spec.rb index 341b210ed..77eec30e6 100644 --- a/spec/models/officing/residence_spec.rb +++ b/spec/models/officing/residence_spec.rb @@ -113,13 +113,13 @@ describe Officing::Residence do describe "allowed age" do it "is not valid if user is under allowed age" do - allow_any_instance_of(described_class).to receive(:date_of_birth).and_return(15.years.ago) + allow_any_instance_of(described_class).to receive(:response_date_of_birth).and_return(15.years.ago) expect(residence).not_to be_valid expect(residence.errors[:year_of_birth]).to include("You don't have the required age to participate") end it "is valid if user is above allowed age" do - allow_any_instance_of(described_class).to receive(:date_of_birth).and_return(16.years.ago) + allow_any_instance_of(described_class).to receive(:response_date_of_birth).and_return(16.years.ago) expect(residence).to be_valid expect(residence.errors[:year_of_birth]).to be_empty end