Force shift dates to start on current date at minimun
This commit is contained in:
@@ -6,7 +6,8 @@ module ShiftsHelper
|
||||
|
||||
def shift_recount_scrutiny_dates(polls)
|
||||
dates = polls.map(&:ends_at).map(&:to_date).sort.inject([]) do |total, date|
|
||||
total << (date..date + Poll::RECOUNT_DURATION).to_a
|
||||
initial_date = date < Date.current ? Date.current : date
|
||||
total << (initial_date..date + Poll::RECOUNT_DURATION).to_a
|
||||
end
|
||||
date_options(dates.flatten.uniq)
|
||||
end
|
||||
@@ -16,7 +17,8 @@ module ShiftsHelper
|
||||
end
|
||||
|
||||
def start_date(polls)
|
||||
polls.map(&:starts_at).min.to_date
|
||||
start_date = polls.map(&:starts_at).min.to_date
|
||||
start_date < Date.current ? Date.current : start_date
|
||||
end
|
||||
|
||||
def end_date(polls)
|
||||
|
||||
@@ -38,7 +38,7 @@ feature 'Admin shifts' do
|
||||
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) }
|
||||
vote_collection_dates = (Date.current..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) }
|
||||
|
||||
visit available_admin_booths_path
|
||||
@@ -53,14 +53,14 @@ feature 'Admin shifts' do
|
||||
|
||||
expect(page).to have_select('shift_date_vote_collection_date', options: ["Select day", *vote_collection_dates])
|
||||
expect(page).not_to have_select('shift_date_recount_scrutiny_date')
|
||||
select I18n.l(poll.starts_at.to_date, format: :long), from: 'shift_date_vote_collection_date'
|
||||
select I18n.l(Date.current, format: :long), from: 'shift_date_vote_collection_date'
|
||||
click_button "Add shift"
|
||||
|
||||
expect(page).to have_content "Shift added"
|
||||
|
||||
within("#shifts") do
|
||||
expect(page).to have_css(".shift", count: 1)
|
||||
expect(page).to have_content(I18n.l(poll.starts_at.to_date, format: :long))
|
||||
expect(page).to have_content(I18n.l(Date.current, format: :long))
|
||||
expect(page).to have_content("Collect Votes")
|
||||
expect(page).to have_content(officer.name)
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user