diff --git a/app/controllers/admin/poll/polls_controller.rb b/app/controllers/admin/poll/polls_controller.rb index 23544e8b2..327527873 100644 --- a/app/controllers/admin/poll/polls_controller.rb +++ b/app/controllers/admin/poll/polls_controller.rb @@ -51,7 +51,7 @@ class Admin::Poll::PollsController < Admin::Poll::BaseController end def booth_assignments - @polls = Poll.current_or_incoming + @polls = Poll.current end private diff --git a/app/controllers/admin/poll/shifts_controller.rb b/app/controllers/admin/poll/shifts_controller.rb index d2ef8e74e..b39270d4f 100644 --- a/app/controllers/admin/poll/shifts_controller.rb +++ b/app/controllers/admin/poll/shifts_controller.rb @@ -6,8 +6,8 @@ class Admin::Poll::ShiftsController < Admin::Poll::BaseController def new load_shifts @shift = ::Poll::Shift.new - @voting_polls = @booth.polls.current_or_incoming - @recount_polls = @booth.polls.current_or_recounting_or_incoming + @voting_polls = @booth.polls.current + @recount_polls = @booth.polls.current_or_recounting end def create diff --git a/app/controllers/polls_controller.rb b/app/controllers/polls_controller.rb index 708f68abb..8378b083d 100644 --- a/app/controllers/polls_controller.rb +++ b/app/controllers/polls_controller.rb @@ -3,7 +3,7 @@ class PollsController < ApplicationController load_and_authorize_resource - has_filters %w{current expired incoming} + has_filters %w[current expired] has_orders %w{most_voted newest oldest}, only: :show ::Poll::Answer # trigger autoload diff --git a/app/models/poll.rb b/app/models/poll.rb index 35b888c90..4733432c3 100644 --- a/app/models/poll.rb +++ b/app/models/poll.rb @@ -28,7 +28,6 @@ class Poll < ActiveRecord::Base validate :date_range scope :current, -> { where('starts_at <= ? and ? <= ends_at', Date.current.beginning_of_day, Date.current.beginning_of_day) } - scope :incoming, -> { where('? < starts_at', Date.current.beginning_of_day) } scope :expired, -> { where('ends_at < ?', Date.current.beginning_of_day) } scope :recounting, -> { Poll.where(ends_at: (Date.current.beginning_of_day - RECOUNT_DURATION)..Date.current.beginning_of_day) } scope :published, -> { where('published = ?', true) } @@ -45,20 +44,12 @@ class Poll < ActiveRecord::Base starts_at <= timestamp && timestamp <= ends_at end - def incoming?(timestamp = Date.current.beginning_of_day) - timestamp < starts_at - end - def expired?(timestamp = Date.current.beginning_of_day) ends_at < timestamp end - def self.current_or_incoming - current + incoming - end - - def self.current_or_recounting_or_incoming - current + recounting + incoming + def self.current_or_recounting + current + recounting end def answerable_by?(user) diff --git a/app/models/poll/booth.rb b/app/models/poll/booth.rb index b9cba45b1..e794a0190 100644 --- a/app/models/poll/booth.rb +++ b/app/models/poll/booth.rb @@ -12,7 +12,7 @@ class Poll end def self.available - where(polls: { id: Poll.current_or_recounting_or_incoming }).includes(:polls) + where(polls: { id: Poll.current_or_recounting }).includes(:polls) end def assignment_on_poll(poll) diff --git a/app/views/polls/_callout.html.erb b/app/views/polls/_callout.html.erb index 8ece61a86..3044b775a 100644 --- a/app/views/polls/_callout.html.erb +++ b/app/views/polls/_callout.html.erb @@ -10,10 +10,6 @@ <%= t('polls.show.cant_answer_verify_html', verify_link: link_to(t('polls.show.verify_link'), verification_path)) %> - <% elsif @poll.incoming? %> -
- <%= t('polls.show.cant_answer_incoming') %> -
<% elsif @poll.expired? %>
<%= t('polls.show.cant_answer_expired') %> diff --git a/app/views/polls/_poll_group.html.erb b/app/views/polls/_poll_group.html.erb index e01320160..711271509 100644 --- a/app/views/polls/_poll_group.html.erb +++ b/app/views/polls/_poll_group.html.erb @@ -75,8 +75,6 @@ <%= link_to poll, class: "button hollow expanded" do %> <% if poll.expired? %> <%= t("polls.index.participate_button_expired") %> - <% elsif poll.incoming? %> - <%= t("polls.index.participate_button_incoming") %> <% else %> <%= t("polls.index.participate_button") %> <% end %> diff --git a/config/locales/en/general.yml b/config/locales/en/general.yml index 20f843999..77058c766 100644 --- a/config/locales/en/general.yml +++ b/config/locales/en/general.yml @@ -462,11 +462,9 @@ en: index: filters: current: "Open" - incoming: "Incoming" expired: "Expired" title: "Polls" participate_button: "Participate in this poll" - participate_button_incoming: "More information" participate_button_expired: "Poll ended" no_geozone_restricted: "All city" geozone_restricted: "Districts" @@ -494,7 +492,6 @@ en: signup: Sign up cant_answer_verify_html: "You must %{verify_link} in order to answer." verify_link: "verify your account" - cant_answer_incoming: "This poll has not yet started." cant_answer_expired: "This poll has finished." cant_answer_wrong_geozone: "This question is not available on your geozone." more_info_title: "More information" diff --git a/config/locales/en/seeds.yml b/config/locales/en/seeds.yml index 4e40cfd63..6c1f4eae1 100644 --- a/config/locales/en/seeds.yml +++ b/config/locales/en/seeds.yml @@ -49,7 +49,6 @@ en: polls: current_poll: "Current Poll" current_poll_geozone_restricted: "Current Poll Geozone Restricted" - incoming_poll: "Incoming Poll" recounting_poll: "Recounting Poll" expired_poll_without_stats: "Expired Poll without Stats & Results" expired_poll_with_stats: "Expired Poll with Stats & Results" diff --git a/config/locales/es/general.yml b/config/locales/es/general.yml index e1a2aa3e2..d1879fbf2 100644 --- a/config/locales/es/general.yml +++ b/config/locales/es/general.yml @@ -462,11 +462,9 @@ es: index: filters: current: "Abiertas" - incoming: "Próximamente" expired: "Terminadas" title: "Votaciones" participate_button: "Participar en esta votación" - participate_button_incoming: "Más información" participate_button_expired: "Votación terminada" no_geozone_restricted: "Toda la ciudad" geozone_restricted: "Distritos" @@ -494,7 +492,6 @@ es: signup: registrarte cant_answer_verify_html: "Por favor %{verify_link} para poder responder." verify_link: "verifica tu cuenta" - cant_answer_incoming: "Esta votación todavía no ha comenzado." cant_answer_expired: "Esta votación ha terminado." cant_answer_wrong_geozone: "Esta votación no está disponible en tu zona." more_info_title: "Más información" diff --git a/config/locales/es/seeds.yml b/config/locales/es/seeds.yml index 567523e2e..9000913af 100644 --- a/config/locales/es/seeds.yml +++ b/config/locales/es/seeds.yml @@ -49,7 +49,6 @@ es: polls: current_poll: "Votación Abierta" current_poll_geozone_restricted: "Votación Abierta restringida por geozona" - incoming_poll: "Siguiente Votación" recounting_poll: "Votación en Recuento" expired_poll_without_stats: "Votación Finalizada (sin Estadísticas o Resultados)" expired_poll_with_stats: "Votación Finalizada (con Estadísticas y Resultado)" diff --git a/db/dev_seeds/polls.rb b/db/dev_seeds/polls.rb index a7884d570..290905032 100644 --- a/db/dev_seeds/polls.rb +++ b/db/dev_seeds/polls.rb @@ -11,10 +11,6 @@ section "Creating polls" do geozone_restricted: true, geozones: Geozone.reorder("RANDOM()").limit(3)) - Poll.create(name: I18n.t('seeds.polls.incoming_poll'), - starts_at: 1.month.from_now, - ends_at: 2.months.from_now) - Poll.create(name: I18n.t('seeds.polls.recounting_poll'), starts_at: 15.days.ago, ends_at: 2.days.ago) diff --git a/spec/factories/polls.rb b/spec/factories/polls.rb index 648a84afa..07649d693 100644 --- a/spec/factories/polls.rb +++ b/spec/factories/polls.rb @@ -10,11 +10,6 @@ FactoryBot.define do ends_at { 2.days.from_now } end - trait :incoming do - starts_at { 2.days.from_now } - ends_at { 1.month.from_now } - end - trait :expired do starts_at { 1.month.ago } ends_at { 15.days.ago } diff --git a/spec/features/admin/poll/booths_spec.rb b/spec/features/admin/poll/booths_spec.rb index d8e399f09..7ca347649 100644 --- a/spec/features/admin/poll/booths_spec.rb +++ b/spec/features/admin/poll/booths_spec.rb @@ -38,27 +38,23 @@ feature 'Admin booths' do scenario "Available" do booth_for_current_poll = create(:poll_booth) - booth_for_incoming_poll = create(:poll_booth) booth_for_expired_poll = create(:poll_booth) current_poll = create(:poll, :current) - incoming_poll = create(:poll, :incoming) expired_poll = create(:poll, :expired) create(:poll_booth_assignment, poll: current_poll, booth: booth_for_current_poll) - create(:poll_booth_assignment, poll: incoming_poll, booth: booth_for_incoming_poll) create(:poll_booth_assignment, poll: expired_poll, booth: booth_for_expired_poll) visit admin_root_path - within('#side_menu') do + within("#side_menu") do click_link "Manage shifts" end - expect(page).to have_css(".booth", count: 2) + expect(page).to have_css(".booth", count: 1) expect(page).to have_content booth_for_current_poll.name - expect(page).to have_content booth_for_incoming_poll.name expect(page).not_to have_content booth_for_expired_poll.name expect(page).not_to have_link "Edit booth" end diff --git a/spec/features/admin/poll/shifts_spec.rb b/spec/features/admin/poll/shifts_spec.rb index 8ee8bfe5c..2796e0208 100644 --- a/spec/features/admin/poll/shifts_spec.rb +++ b/spec/features/admin/poll/shifts_spec.rb @@ -32,7 +32,6 @@ feature 'Admin shifts' do scenario "Create Vote Collection Shift and Recount & Scrutiny Shift on same date", :js do create(:poll) - create(:poll, :incoming) poll = create(:poll, :current) booth = create(:poll_booth) create(:poll_booth_assignment, poll: poll, booth: booth) diff --git a/spec/features/officing/voters_spec.rb b/spec/features/officing/voters_spec.rb index 135bebdc8..a9d37526b 100644 --- a/spec/features/officing/voters_spec.rb +++ b/spec/features/officing/voters_spec.rb @@ -75,9 +75,6 @@ feature 'Voters' do poll_expired = create(:poll, :expired) create(:poll_officer_assignment, officer: officer, booth_assignment: create(:poll_booth_assignment, poll: poll_expired, booth: booth)) - poll_incoming = create(:poll, :incoming) - 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) @@ -93,7 +90,6 @@ feature 'Voters' do expect(page).to have_content poll.name 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 diff --git a/spec/features/polls/polls_spec.rb b/spec/features/polls/polls_spec.rb index 73d8b9658..a1485c132 100644 --- a/spec/features/polls/polls_spec.rb +++ b/spec/features/polls/polls_spec.rb @@ -28,24 +28,15 @@ feature 'Polls' do scenario 'Filtering polls' do create(:poll, name: "Current poll") - create(:poll, :incoming, name: "Incoming poll") create(:poll, :expired, name: "Expired poll") visit polls_path expect(page).to have_content('Current poll') expect(page).to have_link('Participate in this poll') - expect(page).not_to have_content('Incoming poll') - expect(page).not_to have_content('Expired poll') - - visit polls_path(filter: 'incoming') - expect(page).not_to have_content('Current poll') - expect(page).to have_content('Incoming poll') - expect(page).to have_link('More information') expect(page).not_to have_content('Expired poll') visit polls_path(filter: 'expired') expect(page).not_to have_content('Current poll') - expect(page).not_to have_content('Incoming poll') expect(page).to have_content('Expired poll') expect(page).to have_link('Poll ended') end @@ -53,17 +44,10 @@ feature 'Polls' do scenario "Current filter is properly highlighted" do visit polls_path expect(page).not_to have_link('Open') - expect(page).to have_link('Incoming') - expect(page).to have_link('Expired') - - visit polls_path(filter: 'incoming') - expect(page).to have_link('Open') - expect(page).not_to have_link('Incoming') expect(page).to have_link('Expired') visit polls_path(filter: 'expired') expect(page).to have_link('Open') - expect(page).to have_link('Incoming') expect(page).not_to have_link('Expired') end @@ -204,26 +188,6 @@ feature 'Polls' do expect(page).to have_link('Chewbacca', href: verification_path) end - scenario 'Level 2 users in an incoming poll' do - incoming_poll = create(:poll, :incoming, geozone_restricted: true) - incoming_poll.geozones << geozone - - question = create(:poll_question, poll: incoming_poll) - answer1 = create(:poll_question_answer, question: question, title: 'Rey') - answer2 = create(:poll_question_answer, question: question, title: 'Finn') - - login_as(create(:user, :level_two, geozone: geozone)) - - visit poll_path(incoming_poll) - - expect(page).to have_content('Rey') - expect(page).to have_content('Finn') - expect(page).not_to have_link('Rey') - expect(page).not_to have_link('Finn') - - expect(page).to have_content('This poll has not yet started') - end - scenario 'Level 2 users in an expired poll' do expired_poll = create(:poll, :expired, geozone_restricted: true) expired_poll.geozones << geozone diff --git a/spec/models/abilities/common_spec.rb b/spec/models/abilities/common_spec.rb index 93ffa9a48..9b88c0721 100644 --- a/spec/models/abilities/common_spec.rb +++ b/spec/models/abilities/common_spec.rb @@ -33,9 +33,6 @@ describe Abilities::Common do let(:ballot_in_balloting_budget) { create(:budget_ballot, budget: balloting_budget) } let(:current_poll) { create(:poll) } - let(:incoming_poll) { create(:poll, :incoming) } - let(:incoming_poll_from_own_geozone) { create(:poll, :incoming, geozone_restricted: true, geozones: [geozone]) } - let(:incoming_poll_from_other_geozone) { create(:poll, :incoming, geozone_restricted: true, geozones: [create(:geozone)]) } let(:expired_poll) { create(:poll, :expired) } let(:expired_poll_from_own_geozone) { create(:poll, :expired, geozone_restricted: true, geozones: [geozone]) } let(:expired_poll_from_other_geozone) { create(:poll, :expired, geozone_restricted: true, geozones: [create(:geozone)]) } @@ -51,10 +48,6 @@ describe Abilities::Common do let(:expired_poll_question_from_other_geozone) { create(:poll_question, poll: expired_poll_from_other_geozone) } let(:expired_poll_question_from_all_geozones) { create(:poll_question, poll: expired_poll) } - let(:incoming_poll_question_from_own_geozone) { create(:poll_question, poll: incoming_poll_from_own_geozone) } - let(:incoming_poll_question_from_other_geozone) { create(:poll_question, poll: incoming_poll_from_other_geozone) } - let(:incoming_poll_question_from_all_geozones) { create(:poll_question, poll: incoming_poll) } - let(:own_proposal_document) { build(:document, documentable: own_proposal) } let(:proposal_document) { build(:document, documentable: proposal) } let(:own_budget_investment_document) { build(:document, documentable: own_investment_in_accepting_budget) } @@ -188,7 +181,6 @@ describe Abilities::Common do describe "Poll" do it { should be_able_to(:answer, current_poll) } it { should_not be_able_to(:answer, expired_poll) } - it { should_not be_able_to(:answer, incoming_poll) } it { should be_able_to(:answer, poll_question_from_own_geozone) } it { should be_able_to(:answer, poll_question_from_all_geozones) } @@ -198,10 +190,6 @@ describe Abilities::Common do it { should_not be_able_to(:answer, expired_poll_question_from_all_geozones) } it { should_not be_able_to(:answer, expired_poll_question_from_other_geozone) } - it { should_not be_able_to(:answer, incoming_poll_question_from_own_geozone) } - it { should_not be_able_to(:answer, incoming_poll_question_from_all_geozones) } - it { should_not be_able_to(:answer, incoming_poll_question_from_other_geozone) } - context "without geozone" do before { user.geozone = nil } @@ -212,10 +200,6 @@ describe Abilities::Common do it { should_not be_able_to(:answer, expired_poll_question_from_own_geozone) } it { should_not be_able_to(:answer, expired_poll_question_from_all_geozones) } it { should_not be_able_to(:answer, expired_poll_question_from_other_geozone) } - - it { should_not be_able_to(:answer, incoming_poll_question_from_own_geozone) } - it { should_not be_able_to(:answer, incoming_poll_question_from_all_geozones) } - it { should_not be_able_to(:answer, incoming_poll_question_from_other_geozone) } end end @@ -270,7 +254,6 @@ describe Abilities::Common do it { should be_able_to(:answer, current_poll) } it { should_not be_able_to(:answer, expired_poll) } - it { should_not be_able_to(:answer, incoming_poll) } it { should be_able_to(:answer, poll_question_from_own_geozone) } it { should be_able_to(:answer, poll_question_from_all_geozones) } @@ -280,10 +263,6 @@ describe Abilities::Common do it { should_not be_able_to(:answer, expired_poll_question_from_all_geozones) } it { should_not be_able_to(:answer, expired_poll_question_from_other_geozone) } - it { should_not be_able_to(:answer, incoming_poll_question_from_own_geozone) } - it { should_not be_able_to(:answer, incoming_poll_question_from_all_geozones) } - it { should_not be_able_to(:answer, incoming_poll_question_from_other_geozone) } - context "without geozone" do before { user.geozone = nil } it { should_not be_able_to(:answer, poll_question_from_own_geozone) } @@ -293,10 +272,6 @@ describe Abilities::Common do it { should_not be_able_to(:answer, expired_poll_question_from_own_geozone) } it { should_not be_able_to(:answer, expired_poll_question_from_all_geozones) } it { should_not be_able_to(:answer, expired_poll_question_from_other_geozone) } - - it { should_not be_able_to(:answer, incoming_poll_question_from_own_geozone) } - it { should_not be_able_to(:answer, incoming_poll_question_from_all_geozones) } - it { should_not be_able_to(:answer, incoming_poll_question_from_other_geozone) } end end diff --git a/spec/models/poll/booth_spec.rb b/spec/models/poll/booth_spec.rb index e4fccdbb9..990ac816b 100644 --- a/spec/models/poll/booth_spec.rb +++ b/spec/models/poll/booth_spec.rb @@ -26,21 +26,17 @@ describe Poll::Booth do describe "#available" do - it "returns booths associated to current or incoming polls" do + it "returns booths associated to current polls" do booth_for_current_poll = create(:poll_booth) - booth_for_incoming_poll = create(:poll_booth) booth_for_expired_poll = create(:poll_booth) current_poll = create(:poll, :current) - incoming_poll = create(:poll, :incoming) expired_poll = create(:poll, :expired) create(:poll_booth_assignment, poll: current_poll, booth: booth_for_current_poll) - create(:poll_booth_assignment, poll: incoming_poll, booth: booth_for_incoming_poll) create(:poll_booth_assignment, poll: expired_poll, booth: booth_for_expired_poll) expect(described_class.available).to include(booth_for_current_poll) - expect(described_class.available).to include(booth_for_incoming_poll) expect(described_class.available).not_to include(booth_for_expired_poll) end diff --git a/spec/models/poll/poll_spec.rb b/spec/models/poll/poll_spec.rb index f3c114155..f61e0ad61 100644 --- a/spec/models/poll/poll_spec.rb +++ b/spec/models/poll/poll_spec.rb @@ -36,24 +36,14 @@ describe Poll do end describe "#opened?" do - it "returns true only when it isn't too early or too late" do - expect(create(:poll, :incoming)).not_to be_current + it "returns true only when it isn't too late" do expect(create(:poll, :expired)).not_to be_current expect(create(:poll)).to be_current end end - describe "#incoming?" do - it "returns true only when it is too early" do - expect(create(:poll, :incoming)).to be_incoming - expect(create(:poll, :expired)).not_to be_incoming - expect(create(:poll)).not_to be_incoming - end - end - describe "#expired?" do it "returns true only when it is too late" do - expect(create(:poll, :incoming)).not_to be_expired expect(create(:poll, :expired)).to be_expired expect(create(:poll)).not_to be_expired end @@ -66,49 +56,31 @@ describe Poll do end end - describe "#current_or_incoming" do - it "returns current or incoming polls" do - current = create(:poll, :current) - incoming = create(:poll, :incoming) - expired = create(:poll, :expired) - - current_or_incoming = described_class.current_or_incoming - - expect(current_or_incoming).to include(current) - expect(current_or_incoming).to include(incoming) - expect(current_or_incoming).not_to include(expired) - end - end - describe "#recounting" do it "returns polls in recount & scrutiny phase" do current = create(:poll, :current) - incoming = create(:poll, :incoming) expired = create(:poll, :expired) recounting = create(:poll, :recounting) recounting_polls = described_class.recounting expect(recounting_polls).not_to include(current) - expect(recounting_polls).not_to include(incoming) expect(recounting_polls).not_to include(expired) expect(recounting_polls).to include(recounting) end end - describe "#current_or_recounting_or_incoming" do - it "returns current or recounting or incoming polls" do + describe "#current_or_recounting" do + it "returns current or recounting polls" do current = create(:poll, :current) - incoming = create(:poll, :incoming) expired = create(:poll, :expired) recounting = create(:poll, :recounting) - current_or_recounting_or_incoming = described_class.current_or_recounting_or_incoming + current_or_recounting = described_class.current_or_recounting - expect(current_or_recounting_or_incoming).to include(current) - expect(current_or_recounting_or_incoming).to include(recounting) - expect(current_or_recounting_or_incoming).to include(incoming) - expect(current_or_recounting_or_incoming).not_to include(expired) + expect(current_or_recounting).to include(current) + expect(current_or_recounting).to include(recounting) + expect(current_or_recounting).not_to include(expired) end end @@ -117,12 +89,12 @@ describe Poll do let!(:current_poll) { create(:poll) } let!(:expired_poll) { create(:poll, :expired) } - let!(:incoming_poll) { create(:poll, :incoming) } + let!(:current_restricted_poll) { create(:poll, geozone_restricted: true, geozones: [geozone]) } let!(:expired_restricted_poll) { create(:poll, :expired, geozone_restricted: true, geozones: [geozone]) } - let!(:incoming_restricted_poll) { create(:poll, :incoming, geozone_restricted: true, geozones: [geozone]) } - let!(:all_polls) { [current_poll, expired_poll, incoming_poll, current_poll, expired_restricted_poll, incoming_restricted_poll] } - let(:non_current_polls) { [expired_poll, incoming_poll, expired_restricted_poll, incoming_restricted_poll] } + + let!(:all_polls) { [current_poll, expired_poll, current_poll, expired_restricted_poll] } + let(:non_current_polls) { [expired_poll, expired_restricted_poll] } let(:non_user) { nil } let(:level1) { create(:user) }