As mentioned in commits likea586ba806,a7664ad81,006128da5,b41fbfa52andc480cdd91, accessing the database after starting the browser with the `visit` method sometimes results in database corruption and failing tests on our CI due to the process running the test accessing the database after the process running the browser has started. IMHO this is also a bad practice for system tests, since these tests should be checking what users experience. In these cases, however, I haven't been able to test the user experience. For example, it looks like failed census calls for unregistered users aren't displayed anywhere and can only be accessed by manually checking the database. Similarly, there's no interface showing that all the options from a poll have been deleted (which makes sense, since we only display options in the context of their poll) or a place showing the responsible name for a proposal. So we're splitting the tests in two, with the controller test running the database checks.
23 lines
699 B
Ruby
23 lines
699 B
Ruby
require "rails_helper"
|
|
|
|
describe Officing::ResidenceController do
|
|
describe "POST create" do
|
|
it "creates a failed census called when the census data is invalid" do
|
|
officer = create(:poll_officer)
|
|
create(:poll_officer_assignment, officer: officer)
|
|
|
|
sign_in(officer.user)
|
|
|
|
expect do
|
|
post :create, params: {
|
|
residence: { document_type: "1", document_number: "23456789A", year_of_birth: "1980" }
|
|
}
|
|
end.to change { FailedCensusCall.count }.by(1)
|
|
|
|
failed_census_call = FailedCensusCall.last
|
|
expect(failed_census_call.poll_officer).to eq officer
|
|
expect(officer.failed_census_calls).to eq [failed_census_call]
|
|
end
|
|
end
|
|
end
|