Make database queries before starting the browser
When we perform database queries in tests after the process running the browser has started, we sometimes get failures in our test suite due to both the tests and the browser accessing the database at the same time.
This commit is contained in:
@@ -13,7 +13,7 @@ describe "Admin booths", :admin do
|
|||||||
end
|
end
|
||||||
|
|
||||||
scenario "Index" do
|
scenario "Index" do
|
||||||
3.times { create(:poll_booth) }
|
booths = 3.times.map { create(:poll_booth) }
|
||||||
|
|
||||||
visit admin_root_path
|
visit admin_root_path
|
||||||
|
|
||||||
@@ -22,7 +22,6 @@ describe "Admin booths", :admin do
|
|||||||
click_link "Booths location"
|
click_link "Booths location"
|
||||||
end
|
end
|
||||||
|
|
||||||
booths = Poll::Booth.all
|
|
||||||
booths.each do |booth|
|
booths.each do |booth|
|
||||||
within("#booth_#{booth.id}") do
|
within("#booth_#{booth.id}") do
|
||||||
expect(page).to have_content booth.name
|
expect(page).to have_content booth.name
|
||||||
|
|||||||
@@ -212,6 +212,7 @@ describe "Admin polls", :admin do
|
|||||||
booth.booth_assignments.each do |booth_assignment|
|
booth.booth_assignments.each do |booth_assignment|
|
||||||
3.times { create(:poll_officer_assignment, booth_assignment: booth_assignment) }
|
3.times { create(:poll_officer_assignment, booth_assignment: booth_assignment) }
|
||||||
end
|
end
|
||||||
|
officers = Poll::Officer.all
|
||||||
|
|
||||||
visit admin_poll_path(poll)
|
visit admin_poll_path(poll)
|
||||||
|
|
||||||
@@ -219,7 +220,6 @@ describe "Admin polls", :admin do
|
|||||||
|
|
||||||
expect(page).to have_css ".officer", count: 3
|
expect(page).to have_css ".officer", count: 3
|
||||||
|
|
||||||
officers = Poll::Officer.all
|
|
||||||
officers.each do |officer|
|
officers.each do |officer|
|
||||||
within("#officer_#{officer.id}") do
|
within("#officer_#{officer.id}") do
|
||||||
expect(page).to have_content officer.name
|
expect(page).to have_content officer.name
|
||||||
|
|||||||
Reference in New Issue
Block a user