From cc49587fe48c7550c827c2b2ae6271f8adcc382b Mon Sep 17 00:00:00 2001 From: taitus Date: Thu, 25 Apr 2019 17:01:30 +0200 Subject: [PATCH] Update FailedCensusCall with new fields --- app/models/officing/residence.rb | 2 ++ spec/models/officing/residence_spec.rb | 23 +++++++++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/app/models/officing/residence.rb b/app/models/officing/residence.rb index ca0eee9b9..94261e4e9 100644 --- a/app/models/officing/residence.rb +++ b/app/models/officing/residence.rb @@ -53,6 +53,8 @@ class Officing::Residence user: user, document_number: document_number, document_type: document_type, + date_of_birth: date_of_birth, + postal_code: postal_code, year_of_birth: year_of_birth, poll_officer: officer ) diff --git a/spec/models/officing/residence_spec.rb b/spec/models/officing/residence_spec.rb index 77eec30e6..3aa28a6ae 100644 --- a/spec/models/officing/residence_spec.rb +++ b/spec/models/officing/residence_spec.rb @@ -109,6 +109,27 @@ describe Officing::Residence do end end + it "stores failed census calls and set postal_code attribute" do + Setting["remote_census.request.date_of_birth"] = "" + + residence = build(:officing_residence, + :invalid, + document_number: "12345678Z", + postal_code: "00001") + residence.save + + expect(FailedCensusCall.count).to eq(1) + expect(FailedCensusCall.first).to have_attributes( + user_id: residence.user.id, + poll_officer_id: residence.officer.id, + document_number: "12345678Z", + document_type: "1", + date_of_birth: nil, + postal_code: "00001", + year_of_birth: Time.current.year + ) + end + end describe "allowed age" do @@ -198,6 +219,8 @@ describe Officing::Residence do poll_officer_id: residence.officer.id, document_number: "12345678Z", document_type: "1", + date_of_birth: nil, + postal_code: nil, year_of_birth: Time.current.year ) end