Remove trait :current for poll on factories

When we create a poll with "create(:poll)" it is already a current poll.
This commit is contained in:
taitus
2022-08-30 13:23:48 +02:00
committed by Javi Martín
parent 5a0fde4048
commit d0359d584e
11 changed files with 25 additions and 30 deletions

View File

@@ -7,11 +7,6 @@ FactoryBot.define do
starts_at { 1.month.ago }
ends_at { 1.month.from_now }
trait :current do
starts_at { 2.days.ago }
ends_at { 2.days.from_now }
end
trait :expired do
starts_at { 1.month.ago }
ends_at { 15.days.ago }

View File

@@ -33,12 +33,12 @@ describe Abilities::Everyone do
it { should be_able_to(:results, create(:poll, :expired, results_enabled: true)) }
it { should_not be_able_to(:results, create(:poll, :expired, results_enabled: false)) }
it { should_not be_able_to(:results, create(:poll, :current, results_enabled: true)) }
it { should_not be_able_to(:results, create(:poll, results_enabled: true)) }
it { should_not be_able_to(:results, create(:poll, :for_budget, :expired, results_enabled: true)) }
it { should be_able_to(:stats, create(:poll, :expired, stats_enabled: true)) }
it { should_not be_able_to(:stats, create(:poll, :expired, stats_enabled: false)) }
it { should_not be_able_to(:stats, create(:poll, :current, stats_enabled: true)) }
it { should_not be_able_to(:stats, create(:poll, stats_enabled: true)) }
it { should_not be_able_to(:stats, create(:poll, :for_budget, :expired, stats_enabled: true)) }
it { should be_able_to(:read_results, create(:budget, :finished, results_enabled: true)) }

View File

@@ -45,7 +45,7 @@ describe Poll::Booth do
describe ".available" do
it "returns booths associated to current polls" do
booth_for_current_poll = create(:poll_booth, polls: [create(:poll, :current)])
booth_for_current_poll = create(:poll_booth, polls: [create(:poll)])
booth_for_expired_poll = create(:poll_booth, polls: [create(:poll, :expired)])
expect(Poll::Booth.available).to eq [booth_for_current_poll]
@@ -53,7 +53,7 @@ describe Poll::Booth do
end
it "returns polls with multiple translations only once" do
create(:poll_booth, polls: [create(:poll, :current, name: "English", name_es: "Spanish")])
create(:poll_booth, polls: [create(:poll, name: "English", name_es: "Spanish")])
expect(Poll::Booth.available.count).to eq 1
end

View File

@@ -468,7 +468,7 @@ describe Poll do
describe "#recounts_confirmed" do
it "is false for current polls" do
poll = create(:poll, :current)
poll = create(:poll)
expect(poll.recounts_confirmed?).to be false
end

View File

@@ -32,7 +32,7 @@ describe "Admin booths", :admin do
end
scenario "Available" do
booth_for_current_poll = create(:poll_booth, polls: [create(:poll, :current)])
booth_for_current_poll = create(:poll_booth, polls: [create(:poll)])
booth_for_expired_poll = create(:poll_booth, polls: [create(:poll, :expired)])
visit admin_root_path
@@ -74,7 +74,7 @@ describe "Admin booths", :admin do
end
scenario "Edit" do
poll = create(:poll, :current)
poll = create(:poll)
booth = create(:poll_booth, polls: [poll])
visit admin_booths_path
@@ -99,7 +99,7 @@ describe "Admin booths", :admin do
end
scenario "Back link go back to available list when manage shifts" do
poll = create(:poll, :current)
poll = create(:poll)
booth = create(:poll_booth, polls: [poll])
visit available_admin_booths_path

View File

@@ -27,7 +27,7 @@ describe "Admin shifts", :admin do
scenario "Create Vote Collection Shift and Recount & Scrutiny Shift on same date" do
create(:poll)
poll = create(:poll, :current)
poll = create(:poll)
booth = create(:poll_booth, polls: [poll, create(:poll, :expired)])
officer = create(:poll_officer)
vote_collection_dates = (Date.current..poll.ends_at.to_date).to_a.map { |date| I18n.l(date, format: :long) }
@@ -89,7 +89,7 @@ describe "Admin shifts", :admin do
end
scenario "Vote Collection Shift and Recount & Scrutiny Shift don't include already assigned dates to officer" do
poll = create(:poll, :current)
poll = create(:poll)
booth = create(:poll_booth, polls: [poll])
officer = create(:poll_officer)
@@ -137,7 +137,7 @@ describe "Admin shifts", :admin do
end
scenario "Error on create" do
poll = create(:poll, :current)
poll = create(:poll)
booth = create(:poll_booth, polls: [poll])
officer = create(:poll_officer)
@@ -158,7 +158,7 @@ describe "Admin shifts", :admin do
end
scenario "Destroy" do
poll = create(:poll, :current)
poll = create(:poll)
booth = create(:poll_booth, polls: [poll])
officer = create(:poll_officer)

View File

@@ -3,7 +3,7 @@ require "rails_helper"
describe "BudgetPolls", :with_frozen_time do
let(:budget) { create(:budget, :balloting) }
let(:investment) { create(:budget_investment, :selected, budget: budget) }
let(:poll) { create(:poll, :current, budget: budget) }
let(:poll) { create(:poll, budget: budget) }
let(:booth) { create(:poll_booth) }
let(:officer) { create(:poll_officer) }
let(:admin) { create(:administrator) }

View File

@@ -124,7 +124,7 @@ describe "Polls" do
end
scenario "Edit poll is not allowed for current polls" do
poll = create(:poll, :current, related: proposal)
poll = create(:poll, related: proposal)
visit proposal_dashboard_polls_path(proposal)
@@ -232,7 +232,7 @@ describe "Polls" do
end
scenario "View results available for current polls" do
poll = create(:poll, :current, related: proposal)
poll = create(:poll, related: proposal)
visit proposal_dashboard_polls_path(proposal)

View File

@@ -1,7 +1,7 @@
require "rails_helper"
describe "Voters" do
let(:poll) { create(:poll, :current) }
let(:poll) { create(:poll) }
let(:booth) { create(:poll_booth) }
let(:officer) { create(:poll_officer) }
@@ -35,7 +35,7 @@ describe "Voters" do
end
scenario "Cannot vote" do
unvotable_poll = create(:poll, :current, geozone_restricted: true, geozones: [create(:geozone, census_code: "02")])
unvotable_poll = create(:poll, geozone_restricted: true, geozones: [create(:geozone, census_code: "02")])
create(:poll_officer_assignment, officer: officer, poll: unvotable_poll, booth: booth)
set_officing_booth(booth)
@@ -49,7 +49,7 @@ describe "Voters" do
end
scenario "Already voted" do
poll2 = create(:poll, :current)
poll2 = create(:poll)
create(:poll_officer_assignment, officer: officer, poll: poll2, booth: booth)
user = create(:user, :level_two)
@@ -84,7 +84,7 @@ describe "Voters" do
context "Polls displayed to officers" do
scenario "Display current polls assigned to a booth" do
poll = create(:poll, :current)
poll = create(:poll)
create(:poll_officer_assignment, officer: officer, poll: poll, booth: booth)
set_officing_booth(booth)
@@ -96,7 +96,7 @@ describe "Voters" do
end
scenario "Display polls that the user can vote" do
votable_poll = create(:poll, :current, geozone_restricted: true, geozones: [Geozone.first])
votable_poll = create(:poll, geozone_restricted: true, geozones: [Geozone.first])
create(:poll_officer_assignment, officer: officer, poll: votable_poll, booth: booth)
set_officing_booth(booth)
@@ -108,7 +108,7 @@ describe "Voters" do
end
scenario "Display polls that the user cannot vote" do
unvotable_poll = create(:poll, :current, geozone_restricted: true, geozones: [create(:geozone, census_code: "02")])
unvotable_poll = create(:poll, geozone_restricted: true, geozones: [create(:geozone, census_code: "02")])
create(:poll_officer_assignment, officer: officer, poll: unvotable_poll, booth: booth)
set_officing_booth(booth)
@@ -132,8 +132,8 @@ describe "Voters" do
end
scenario "Do not display polls from other booths" do
poll1 = create(:poll, :current)
poll2 = create(:poll, :current)
poll1 = create(:poll)
poll2 = create(:poll)
booth1 = create(:poll_booth)
booth2 = create(:poll_booth)

View File

@@ -543,7 +543,7 @@ describe "Polls" do
end
scenario "Don't show poll results and stats if is not expired" do
poll = create(:poll, :current, results_enabled: true, stats_enabled: true)
poll = create(:poll, results_enabled: true, stats_enabled: true)
user = create(:user)
login_as user

View File

@@ -2,7 +2,7 @@ require "rails_helper"
describe "Voter" do
context "Origin", :with_frozen_time do
let(:poll) { create(:poll, :current) }
let(:poll) { create(:poll) }
let(:question) { create(:poll_question, poll: poll) }
let(:booth) { create(:poll_booth) }
let(:officer) { create(:poll_officer) }