Simplify assigning officer to a poll in specs
While it could be argued we're hiding the real way we've defined associations in our models, the tests are so much easier to read when we don't have so many lines just creating data. Furthermore, developers who care about vertically aligning the code will be glad to see some variables disrupting this alignment are now gone.
This commit is contained in:
@@ -10,8 +10,7 @@ describe "Voters" do
|
||||
login_as(officer.user)
|
||||
create(:geozone, :in_census)
|
||||
create(:poll_shift, officer: officer, booth: booth, date: Date.current, task: :vote_collection)
|
||||
booth_assignment = create(:poll_booth_assignment, poll: poll, booth: booth)
|
||||
create(:poll_officer_assignment, officer: officer, booth_assignment: booth_assignment)
|
||||
create(:poll_officer_assignment, officer: officer, poll: poll, booth: booth)
|
||||
set_officing_booth(booth)
|
||||
end
|
||||
|
||||
@@ -38,8 +37,7 @@ describe "Voters" do
|
||||
|
||||
scenario "Cannot vote" do
|
||||
unvotable_poll = create(:poll, :current, geozone_restricted: true, geozones: [create(:geozone, census_code: "02")])
|
||||
booth_assignment = create(:poll_booth_assignment, poll: unvotable_poll, booth: booth)
|
||||
officer_assignment = create(:poll_officer_assignment, officer: officer, booth_assignment: booth_assignment)
|
||||
officer_assignment = create(:poll_officer_assignment, officer: officer, poll: unvotable_poll, booth: booth)
|
||||
|
||||
set_officing_booth(booth)
|
||||
visit new_officing_residence_path
|
||||
@@ -53,8 +51,7 @@ describe "Voters" do
|
||||
|
||||
scenario "Already voted" do
|
||||
poll2 = create(:poll, :current)
|
||||
booth_assignment = create(:poll_booth_assignment, poll: poll2, booth: booth)
|
||||
create(:poll_officer_assignment, officer: officer, booth_assignment: booth_assignment)
|
||||
create(:poll_officer_assignment, officer: officer, poll: poll2, booth: booth)
|
||||
|
||||
user = create(:user, :level_two)
|
||||
voter = create(:poll_voter, poll: poll, user: user)
|
||||
@@ -90,8 +87,7 @@ describe "Voters" do
|
||||
|
||||
scenario "Display current polls assigned to a booth" do
|
||||
poll = create(:poll, :current)
|
||||
booth_assignment = create(:poll_booth_assignment, poll: poll, booth: booth)
|
||||
officer_assignment = create(:poll_officer_assignment, officer: officer, booth_assignment: booth_assignment)
|
||||
officer_assignment = create(:poll_officer_assignment, officer: officer, poll: poll, booth: booth)
|
||||
|
||||
set_officing_booth(booth)
|
||||
visit new_officing_residence_path
|
||||
@@ -103,8 +99,7 @@ describe "Voters" do
|
||||
|
||||
scenario "Display polls that the user can vote" do
|
||||
votable_poll = create(:poll, :current, geozone_restricted: true, geozones: [Geozone.first])
|
||||
booth_assignment = create(:poll_booth_assignment, poll: votable_poll, booth: booth)
|
||||
officer_assignment = create(:poll_officer_assignment, officer: officer, booth_assignment: booth_assignment)
|
||||
officer_assignment = create(:poll_officer_assignment, officer: officer, poll: votable_poll, booth: booth)
|
||||
|
||||
set_officing_booth(booth)
|
||||
visit new_officing_residence_path
|
||||
@@ -116,8 +111,7 @@ describe "Voters" do
|
||||
|
||||
scenario "Display polls that the user cannot vote" do
|
||||
unvotable_poll = create(:poll, :current, geozone_restricted: true, geozones: [create(:geozone, census_code: "02")])
|
||||
booth_assignment = create(:poll_booth_assignment, poll: unvotable_poll, booth: booth)
|
||||
officer_assignment = create(:poll_officer_assignment, officer: officer, booth_assignment: booth_assignment)
|
||||
officer_assignment = create(:poll_officer_assignment, officer: officer, poll: unvotable_poll, booth: booth)
|
||||
|
||||
set_officing_booth(booth)
|
||||
visit new_officing_residence_path
|
||||
@@ -129,8 +123,7 @@ describe "Voters" do
|
||||
|
||||
scenario "Do not display expired polls" do
|
||||
expired_poll = create(:poll, :expired)
|
||||
booth_assignment = create(:poll_booth_assignment, poll: expired_poll, booth: booth)
|
||||
officer_assignment = create(:poll_officer_assignment, officer: officer, booth_assignment: booth_assignment)
|
||||
officer_assignment = create(:poll_officer_assignment, officer: officer, poll: expired_poll, booth: booth)
|
||||
|
||||
set_officing_booth(booth)
|
||||
visit new_officing_residence_path
|
||||
@@ -147,11 +140,8 @@ describe "Voters" do
|
||||
booth1 = create(:poll_booth)
|
||||
booth2 = create(:poll_booth)
|
||||
|
||||
booth_assignment1 = create(:poll_booth_assignment, poll: poll1, booth: booth1)
|
||||
booth_assignment2 = create(:poll_booth_assignment, poll: poll2, booth: booth2)
|
||||
|
||||
officer_assignment1 = create(:poll_officer_assignment, officer: officer, booth_assignment: booth_assignment1)
|
||||
officer_assignment2 = create(:poll_officer_assignment, officer: officer, booth_assignment: booth_assignment2)
|
||||
officer_assignment1 = create(:poll_officer_assignment, officer: officer, poll: poll1, booth: booth1)
|
||||
officer_assignment2 = create(:poll_officer_assignment, officer: officer, poll: poll2, booth: booth2)
|
||||
|
||||
set_officing_booth(booth1)
|
||||
visit new_officing_residence_path
|
||||
|
||||
Reference in New Issue
Block a user