Merge pull request #3280 from consul/next-filters
[Backport] Removes next/incoming filters
This commit is contained in:
@@ -21,17 +21,6 @@ FactoryBot.define do
|
||||
result_publication_enabled true
|
||||
published true
|
||||
|
||||
trait :next do
|
||||
start_date { Date.current + 2.days }
|
||||
end_date { Date.current + 8.days }
|
||||
debate_start_date { Date.current + 2.days }
|
||||
debate_end_date { Date.current + 4.days }
|
||||
draft_publication_date { Date.current + 5.days }
|
||||
allegations_start_date { Date.current + 5.days }
|
||||
allegations_end_date { Date.current + 7.days }
|
||||
result_publication_date { Date.current + 8.days }
|
||||
end
|
||||
|
||||
trait :past do
|
||||
start_date { Date.current - 12.days }
|
||||
end_date { Date.current - 2.days }
|
||||
|
||||
@@ -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 }
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -26,14 +26,11 @@ feature 'Legislation' do
|
||||
|
||||
context 'processes home page' do
|
||||
|
||||
scenario 'No processes to be listed' do
|
||||
scenario "No processes to be listed" do
|
||||
visit legislation_processes_path
|
||||
expect(page).to have_text "There aren't open processes"
|
||||
|
||||
visit legislation_processes_path(filter: 'next')
|
||||
expect(page).to have_text "There aren't planned processes"
|
||||
|
||||
visit legislation_processes_path(filter: 'past')
|
||||
visit legislation_processes_path(filter: "past")
|
||||
expect(page).to have_text "There aren't past processes"
|
||||
end
|
||||
|
||||
@@ -90,24 +87,16 @@ feature 'Legislation' do
|
||||
|
||||
scenario 'Filtering processes' do
|
||||
create(:legislation_process, title: "Process open")
|
||||
create(:legislation_process, :next, title: "Process next")
|
||||
create(:legislation_process, :past, title: "Process past")
|
||||
create(:legislation_process, :in_draft_phase, title: "Process in draft phase")
|
||||
|
||||
visit legislation_processes_path
|
||||
expect(page).to have_content('Process open')
|
||||
expect(page).not_to have_content('Process next')
|
||||
expect(page).not_to have_content('Process past')
|
||||
expect(page).not_to have_content('Process in draft phase')
|
||||
|
||||
visit legislation_processes_path(filter: 'next')
|
||||
expect(page).not_to have_content('Process open')
|
||||
expect(page).to have_content('Process next')
|
||||
expect(page).not_to have_content('Process past')
|
||||
|
||||
visit legislation_processes_path(filter: 'past')
|
||||
expect(page).not_to have_content('Process open')
|
||||
expect(page).not_to have_content('Process next')
|
||||
expect(page).to have_content('Process past')
|
||||
end
|
||||
|
||||
@@ -115,10 +104,8 @@ feature 'Legislation' do
|
||||
before do
|
||||
create(:legislation_process, title: "published")
|
||||
create(:legislation_process, :not_published, title: "not published")
|
||||
[:next, :past].each do |trait|
|
||||
create(:legislation_process, trait, title: "#{trait} published")
|
||||
create(:legislation_process, :not_published, trait, title: "#{trait} not published")
|
||||
end
|
||||
create(:legislation_process, :past, title: "past published")
|
||||
create(:legislation_process, :not_published, :past, title: "past not published")
|
||||
end
|
||||
|
||||
it "aren't listed" do
|
||||
@@ -132,17 +119,6 @@ feature 'Legislation' do
|
||||
expect(page).to have_content('published')
|
||||
end
|
||||
|
||||
it "aren't listed with next filter" do
|
||||
visit legislation_processes_path(filter: 'next')
|
||||
expect(page).not_to have_content('not published')
|
||||
expect(page).to have_content('next published')
|
||||
|
||||
login_as(administrator)
|
||||
visit legislation_processes_path(filter: 'next')
|
||||
expect(page).not_to have_content('not published')
|
||||
expect(page).to have_content('next published')
|
||||
end
|
||||
|
||||
it "aren't listed with past filter" do
|
||||
visit legislation_processes_path(filter: 'past')
|
||||
expect(page).not_to have_content('not published')
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -144,14 +144,6 @@ describe Legislation::Process do
|
||||
expect(processes_not_in_draft).not_to include(process_with_draft_only_today)
|
||||
end
|
||||
|
||||
it "filters next" do
|
||||
next_processes = ::Legislation::Process.next
|
||||
|
||||
expect(next_processes).to include(process_2)
|
||||
expect(next_processes).not_to include(process_1)
|
||||
expect(next_processes).not_to include(process_3)
|
||||
end
|
||||
|
||||
it "filters past" do
|
||||
past_processes = ::Legislation::Process.past
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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) }
|
||||
|
||||
Reference in New Issue
Block a user