From ff5f7ad401ca7469cc6d23218da7f9284ded96de Mon Sep 17 00:00:00 2001 From: taitus Date: Thu, 25 Apr 2019 16:58:46 +0200 Subject: [PATCH] =?UTF-8?q?Naming:=20Ambiguos=20=E2=80=98date=5Fof=5Fbirth?= =?UTF-8?q?'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Actually we are using 'date_of_birth' as method and as attribute accessor. - Refactor 'date_of_birth' method to 'response_date_of_birth’ --- app/models/officing/residence.rb | 6 +++--- spec/models/officing/residence_spec.rb | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) 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