From 79c8c2f826dc53eb4ca1219c65d8efc4f36f9c57 Mon Sep 17 00:00:00 2001 From: Bertocq Date: Fri, 13 Oct 2017 16:55:40 +0200 Subject: [PATCH] Add scope on shift creation date ranges to current/recounting/incoming polls, plus cover with test --- app/views/admin/poll/shifts/_form.html.erb | 4 ++-- spec/features/admin/poll/shifts_spec.rb | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/app/views/admin/poll/shifts/_form.html.erb b/app/views/admin/poll/shifts/_form.html.erb index 1a13edf45..4004a949b 100644 --- a/app/views/admin/poll/shifts/_form.html.erb +++ b/app/views/admin/poll/shifts/_form.html.erb @@ -24,12 +24,12 @@
<%= select 'shift[date]', 'vote_collection_date', - options_for_select(shift_vote_collection_dates(@booth.polls)), + options_for_select(shift_vote_collection_dates(@booth.polls.current_or_incoming)), { prompt: t("admin.poll_shifts.new.select_date"), label: false }, class: 'js-shift-vote-collection-dates' %> <%= select 'shift[date]', 'recount_scrutiny_date', - options_for_select(shift_recount_scrutiny_dates(@booth.polls)), + options_for_select(shift_recount_scrutiny_dates(@booth.polls.current_or_recounting_or_incoming)), { prompt: t("admin.poll_shifts.new.select_date"), label: false }, class: 'js-shift-recount-scrutiny-dates', diff --git a/spec/features/admin/poll/shifts_spec.rb b/spec/features/admin/poll/shifts_spec.rb index 2ac290216..edefd0844 100644 --- a/spec/features/admin/poll/shifts_spec.rb +++ b/spec/features/admin/poll/shifts_spec.rb @@ -35,7 +35,8 @@ feature 'Admin shifts' do create(:poll, :incoming) poll = create(:poll, :current) booth = create(:poll_booth) - assignment = create(:poll_booth_assignment, poll: poll, booth: booth) + create(:poll_booth_assignment, poll: poll, booth: booth) + create(:poll_booth_assignment, poll: create(:poll, :expired), booth: booth) officer = create(:poll_officer) vote_collection_dates = (poll.starts_at.to_date..poll.ends_at.to_date).to_a.map { |date| I18n.l(date, format: :long) } recount_scrutiny_dates = (poll.ends_at.to_date..poll.ends_at.to_date + 1.week).to_a.map { |date| I18n.l(date, format: :long) }