mirror of
https://github.com/openSUSE/osem.git
synced 2026-08-13 19:54:02 +00:00
Merge pull request #1136 from differentreality/fix_voting
voting period is open when voting dates are not set
This commit is contained in:
commit
d6618fd3af
3 changed files with 6 additions and 6 deletions
|
|
@ -4,7 +4,7 @@ module ApplicationHelper
|
|||
#
|
||||
def voting_open_or_close(program)
|
||||
return if program.voting_period?
|
||||
if program.voting_start_date > Date.today
|
||||
if program.voting_start_date > Time.current
|
||||
return 'Voting period has not started yet!'
|
||||
else # voting_end_date > Date.today because voting_start_date < voting_end_date
|
||||
return 'Voting period is over!'
|
||||
|
|
|
|||
|
|
@ -72,16 +72,16 @@ class Program < ActiveRecord::Base
|
|||
def show_voting?
|
||||
return true unless blind_voting
|
||||
|
||||
Date.today > voting_end_date
|
||||
Time.current > voting_end_date
|
||||
end
|
||||
|
||||
##
|
||||
# Checks if we are still in voting period
|
||||
# ====Returns
|
||||
# * +true+ -> If the voting period is not over yet
|
||||
# * +true+ -> If the voting period is not over yet (or if the voting dates are not set)
|
||||
# * +false+ -> If the voting period is over
|
||||
def voting_period?
|
||||
return false unless voting_start_date && voting_end_date
|
||||
return true unless voting_start_date && voting_end_date
|
||||
|
||||
(voting_start_date.to_datetime..voting_end_date.to_datetime).cover? Time.current
|
||||
end
|
||||
|
|
|
|||
|
|
@ -90,8 +90,8 @@ describe Program do
|
|||
end
|
||||
|
||||
describe 'voting_period?' do
|
||||
it 'retuns false when voting dates are not set' do
|
||||
expect(program.voting_period?).to eq false
|
||||
it 'retuns true when voting dates are not set' do
|
||||
expect(program.voting_period?).to eq true
|
||||
end
|
||||
|
||||
shared_examples 'voting period' do |voting_start_date, voting_end_date, returns|
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue