Adds specs for creating failed officing census calls
This commit is contained in:
@@ -8,7 +8,7 @@ class Officing::ResidenceController < Officing::BaseController
|
|||||||
end
|
end
|
||||||
|
|
||||||
def create
|
def create
|
||||||
@residence = Officing::Residence.new(residence_params)
|
@residence = Officing::Residence.new(residence_params.merge(officer: current_user.poll_officer))
|
||||||
if @residence.save
|
if @residence.save
|
||||||
redirect_to new_officing_voter_path(id: @residence.user.id), notice: t("officing.residence.flash.create")
|
redirect_to new_officing_voter_path(id: @residence.user.id), notice: t("officing.residence.flash.create")
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -52,10 +52,11 @@ feature 'Residence' do
|
|||||||
end
|
end
|
||||||
|
|
||||||
click_button 'Validate document'
|
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
|
end
|
||||||
|
|
||||||
scenario "Error on Census (document number)" do
|
scenario "Error on Census (document number)" do
|
||||||
|
initial_failed_census_calls_count = officer.failed_census_calls_count
|
||||||
within("#side_menu") do
|
within("#side_menu") do
|
||||||
click_link "Validate document"
|
click_link "Validate document"
|
||||||
end
|
end
|
||||||
@@ -67,6 +68,13 @@ feature 'Residence' do
|
|||||||
click_button 'Validate document'
|
click_button 'Validate document'
|
||||||
|
|
||||||
expect(page).to have_content 'The Census was unable to verify this 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
|
end
|
||||||
|
|
||||||
scenario "Error on Census (year of birth)" do
|
scenario "Error on Census (year of birth)" do
|
||||||
|
|||||||
@@ -93,5 +93,19 @@ describe Officing::Residence do
|
|||||||
expect(user.geozone).to eq(geozone)
|
expect(user.geozone).to eq(geozone)
|
||||||
end
|
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
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user