Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Flaky spec: booth_spec.rb #1343

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 13 additions & 7 deletions spec/features/officing/booth_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

feature 'Booth' do

before do
allow(Date).to receive(:current).and_return Date.new(2018,1,1)
allow(Date).to receive(:today).and_return Date.new(2018,1,1)
allow(Time).to receive(:current).and_return Time.zone.parse("2018-01-01 12:00:00")
end

scenario "Officer with no booth assignments today" do
officer = create(:poll_officer)

Expand All @@ -12,7 +18,7 @@

scenario "Officer with booth assignments another day" do
officer = create(:poll_officer)
create(:poll_officer_assignment, officer: officer, date: 1.day.from_now)
create(:poll_officer_assignment, officer: officer, date: Date.current + 1.day)

login_through_form_as_officer(officer.user)

Expand All @@ -26,7 +32,7 @@
booth = create(:poll_booth)

booth_assignment = create(:poll_booth_assignment, poll: poll, booth: booth)
create(:poll_officer_assignment, officer: officer, booth_assignment: booth_assignment, date: Date.today)
create(:poll_officer_assignment, officer: officer, booth_assignment: booth_assignment, date: Date.current)

login_through_form_as_officer(officer.user)

Expand All @@ -45,8 +51,8 @@
ba1 = create(:poll_booth_assignment, poll: poll, booth: booth1)
ba2 = create(:poll_booth_assignment, poll: poll, booth: booth2)

create(:poll_officer_assignment, officer: officer, booth_assignment: ba1, date: Date.today)
create(:poll_officer_assignment, officer: officer, booth_assignment: ba2, date: Date.today)
create(:poll_officer_assignment, officer: officer, booth_assignment: ba1, date: Date.current)
create(:poll_officer_assignment, officer: officer, booth_assignment: ba2, date: Date.current)

login_through_form_as_officer(officer.user)

Expand All @@ -73,9 +79,9 @@
ba2 = create(:poll_booth_assignment, poll: poll2, booth: booth2)
ba3 = create(:poll_booth_assignment, poll: poll2, booth: booth2)

create(:poll_officer_assignment, officer: officer, booth_assignment: ba1, date: Date.today)
create(:poll_officer_assignment, officer: officer, booth_assignment: ba2, date: Date.today)
create(:poll_officer_assignment, officer: officer, booth_assignment: ba3, date: Date.today)
create(:poll_officer_assignment, officer: officer, booth_assignment: ba1, date: Date.current)
create(:poll_officer_assignment, officer: officer, booth_assignment: ba2, date: Date.current)
create(:poll_officer_assignment, officer: officer, booth_assignment: ba3, date: Date.current)

login_through_form_as_officer(officer.user)

Expand Down