Skip to content

Commit

Permalink
Fix for issues 1202, 1203 and 1204. Stub the Date and Time functions …
Browse files Browse the repository at this point in the history
…in the booth_spec test and changed all the Date.current functions for a hardcoded date so that it won't give errors when running tests at midnight.
  • Loading branch information
iagirre committed Mar 14, 2018
1 parent 0de72dd commit 4863da8
Showing 1 changed file with 13 additions and 7 deletions.
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

0 comments on commit 4863da8

Please sign in to comment.