Adds specs for creating failed officing census calls
This commit is contained in:
@@ -8,7 +8,7 @@ class Officing::ResidenceController < Officing::BaseController
|
||||
end
|
||||
|
||||
def create
|
||||
@residence = Officing::Residence.new(residence_params)
|
||||
@residence = Officing::Residence.new(residence_params.merge(officer: current_user.poll_officer))
|
||||
if @residence.save
|
||||
redirect_to new_officing_voter_path(id: @residence.user.id), notice: t("officing.residence.flash.create")
|
||||
else
|
||||
@@ -34,4 +34,4 @@ class Officing::ResidenceController < Officing::BaseController
|
||||
redirect_to officing_root_path, notice: t("officing.residence.flash.not_allowed")
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -52,10 +52,11 @@ feature 'Residence' do
|
||||
end
|
||||
|
||||
click_button 'Validate document'
|
||||
expect(page).to have_content /\d errors? prevented the verification of this document/
|
||||
expect(page).to have_content(/\d errors? prevented the verification of this document/)
|
||||
end
|
||||
|
||||
scenario "Error on Census (document number)" do
|
||||
initial_failed_census_calls_count = officer.failed_census_calls_count
|
||||
within("#side_menu") do
|
||||
click_link "Validate document"
|
||||
end
|
||||
@@ -67,6 +68,13 @@ feature 'Residence' do
|
||||
click_button 'Validate document'
|
||||
|
||||
expect(page).to have_content 'The Census was unable to verify this document'
|
||||
|
||||
officer.reload
|
||||
fcc = FailedCensusCall.last
|
||||
expect(fcc).to be
|
||||
expect(fcc.poll_officer).to eq(officer)
|
||||
expect(officer.failed_census_calls.last).to eq(fcc)
|
||||
expect(officer.failed_census_calls_count).to eq(initial_failed_census_calls_count + 1)
|
||||
end
|
||||
|
||||
scenario "Error on Census (year of birth)" do
|
||||
@@ -85,4 +93,4 @@ feature 'Residence' do
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
@@ -93,5 +93,19 @@ describe Officing::Residence do
|
||||
expect(user.geozone).to eq(geozone)
|
||||
end
|
||||
|
||||
it "stores failed census calls" do
|
||||
residence = build(:officing_residence, :invalid, document_number: "12345678Z")
|
||||
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",
|
||||
year_of_birth: Time.current.year
|
||||
})
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user