Merge pull request #3280 from consul/next-filters

[Backport] Removes next/incoming filters
This commit is contained in:
Alberto
2019-02-11 20:43:09 +01:00
committed by GitHub
142 changed files with 27 additions and 454 deletions

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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) }