Include the answerable by user scope back on Poll list for officer voting panel

This commit is contained in:
Bertocq
2017-10-04 17:05:25 +02:00
parent e1a7fc5dfa
commit 24ef7984a3
2 changed files with 13 additions and 5 deletions

View File

@@ -4,7 +4,7 @@ class Officing::VotersController < Officing::BaseController
def new
@user = User.find(params[:id])
booths = current_user.poll_officer.shifts.current.vote_collection.pluck(:booth_id).uniq
@polls = Poll.current.where(id: Poll::BoothAssignment.where(booth: booths).pluck(:poll_id).uniq)
@polls = Poll.answerable_by(@user).where(id: Poll::BoothAssignment.where(booth: booths).pluck(:poll_id).uniq)
end
def create

View File

@@ -64,7 +64,7 @@ feature 'Voters' do
expect(page).to have_content poll.name
end
scenario "Display only current polls on which officer has a voting shift today", :js do
scenario "Display only current polls on which officer has a voting shift today, and user can answer", :js do
poll_current = create(:poll, :current)
second_booth = create(:poll_booth)
booth_assignment = create(:poll_booth_assignment, poll: poll_current, booth: second_booth)
@@ -73,11 +73,17 @@ feature 'Voters' do
create(:poll_shift, officer: officer, booth: second_booth, date: Date.tomorrow, task: :vote_collection)
poll_expired = create(:poll, :expired)
booth_assignment = create(:poll_booth_assignment, poll: poll_expired, booth: booth)
create(:poll_officer_assignment, officer: officer, booth_assignment: booth_assignment)
create(:poll_officer_assignment, officer: officer, booth_assignment: create(:poll_booth_assignment, poll: poll_expired, booth: booth))
poll_incoming = create(:poll, :incoming)
booth_assignment = create(:poll_booth_assignment, poll: poll_incoming, booth: booth)
create(:poll_officer_assignment, officer: officer, booth_assignment: create(:poll_booth_assignment, poll: poll_incoming, booth: booth))
poll_geozone_restricted_in = create(:poll, :current, geozone_restricted: true, geozones: [Geozone.first])
booth_assignment = create(:poll_booth_assignment, poll: poll_geozone_restricted_in, booth: booth)
create(:poll_officer_assignment, officer: officer, booth_assignment: booth_assignment)
poll_geozone_restricted_out = create(:poll, :current, geozone_restricted: true, geozones: [create(:geozone, census_code: "02")])
booth_assignment = create(:poll_booth_assignment, poll: poll_geozone_restricted_out, booth: booth)
create(:poll_officer_assignment, officer: officer, booth_assignment: booth_assignment)
visit new_officing_residence_path
@@ -88,5 +94,7 @@ feature 'Voters' do
expect(page).not_to have_content poll_current.name
expect(page).not_to have_content poll_expired.name
expect(page).not_to have_content poll_incoming.name
expect(page).to have_content poll_geozone_restricted_in.name
expect(page).not_to have_content poll_geozone_restricted_out.name
end
end