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:
@@ -7,11 +7,6 @@ FactoryBot.define do
|
|||||||
starts_at { 1.month.ago }
|
starts_at { 1.month.ago }
|
||||||
ends_at { 1.month.from_now }
|
ends_at { 1.month.from_now }
|
||||||
|
|
||||||
trait :current do
|
|
||||||
starts_at { 2.days.ago }
|
|
||||||
ends_at { 2.days.from_now }
|
|
||||||
end
|
|
||||||
|
|
||||||
trait :expired do
|
trait :expired do
|
||||||
starts_at { 1.month.ago }
|
starts_at { 1.month.ago }
|
||||||
ends_at { 15.days.ago }
|
ends_at { 15.days.ago }
|
||||||
|
|||||||
@@ -33,12 +33,12 @@ describe Abilities::Everyone do
|
|||||||
|
|
||||||
it { should be_able_to(:results, create(:poll, :expired, results_enabled: true)) }
|
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, :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_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 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, :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_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)) }
|
it { should be_able_to(:read_results, create(:budget, :finished, results_enabled: true)) }
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ describe Poll::Booth do
|
|||||||
|
|
||||||
describe ".available" do
|
describe ".available" do
|
||||||
it "returns booths associated to current polls" 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)])
|
booth_for_expired_poll = create(:poll_booth, polls: [create(:poll, :expired)])
|
||||||
|
|
||||||
expect(Poll::Booth.available).to eq [booth_for_current_poll]
|
expect(Poll::Booth.available).to eq [booth_for_current_poll]
|
||||||
@@ -53,7 +53,7 @@ describe Poll::Booth do
|
|||||||
end
|
end
|
||||||
|
|
||||||
it "returns polls with multiple translations only once" do
|
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
|
expect(Poll::Booth.available.count).to eq 1
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -468,7 +468,7 @@ describe Poll do
|
|||||||
|
|
||||||
describe "#recounts_confirmed" do
|
describe "#recounts_confirmed" do
|
||||||
it "is false for current polls" do
|
it "is false for current polls" do
|
||||||
poll = create(:poll, :current)
|
poll = create(:poll)
|
||||||
|
|
||||||
expect(poll.recounts_confirmed?).to be false
|
expect(poll.recounts_confirmed?).to be false
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ describe "Admin booths", :admin do
|
|||||||
end
|
end
|
||||||
|
|
||||||
scenario "Available" do
|
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)])
|
booth_for_expired_poll = create(:poll_booth, polls: [create(:poll, :expired)])
|
||||||
|
|
||||||
visit admin_root_path
|
visit admin_root_path
|
||||||
@@ -74,7 +74,7 @@ describe "Admin booths", :admin do
|
|||||||
end
|
end
|
||||||
|
|
||||||
scenario "Edit" do
|
scenario "Edit" do
|
||||||
poll = create(:poll, :current)
|
poll = create(:poll)
|
||||||
booth = create(:poll_booth, polls: [poll])
|
booth = create(:poll_booth, polls: [poll])
|
||||||
|
|
||||||
visit admin_booths_path
|
visit admin_booths_path
|
||||||
@@ -99,7 +99,7 @@ describe "Admin booths", :admin do
|
|||||||
end
|
end
|
||||||
|
|
||||||
scenario "Back link go back to available list when manage shifts" do
|
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])
|
booth = create(:poll_booth, polls: [poll])
|
||||||
|
|
||||||
visit available_admin_booths_path
|
visit available_admin_booths_path
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ describe "Admin shifts", :admin do
|
|||||||
|
|
||||||
scenario "Create Vote Collection Shift and Recount & Scrutiny Shift on same date" do
|
scenario "Create Vote Collection Shift and Recount & Scrutiny Shift on same date" do
|
||||||
create(:poll)
|
create(:poll)
|
||||||
poll = create(:poll, :current)
|
poll = create(:poll)
|
||||||
booth = create(:poll_booth, polls: [poll, create(:poll, :expired)])
|
booth = create(:poll_booth, polls: [poll, create(:poll, :expired)])
|
||||||
officer = create(:poll_officer)
|
officer = create(:poll_officer)
|
||||||
vote_collection_dates = (Date.current..poll.ends_at.to_date).to_a.map { |date| I18n.l(date, format: :long) }
|
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
|
end
|
||||||
|
|
||||||
scenario "Vote Collection Shift and Recount & Scrutiny Shift don't include already assigned dates to officer" do
|
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])
|
booth = create(:poll_booth, polls: [poll])
|
||||||
officer = create(:poll_officer)
|
officer = create(:poll_officer)
|
||||||
|
|
||||||
@@ -137,7 +137,7 @@ describe "Admin shifts", :admin do
|
|||||||
end
|
end
|
||||||
|
|
||||||
scenario "Error on create" do
|
scenario "Error on create" do
|
||||||
poll = create(:poll, :current)
|
poll = create(:poll)
|
||||||
booth = create(:poll_booth, polls: [poll])
|
booth = create(:poll_booth, polls: [poll])
|
||||||
officer = create(:poll_officer)
|
officer = create(:poll_officer)
|
||||||
|
|
||||||
@@ -158,7 +158,7 @@ describe "Admin shifts", :admin do
|
|||||||
end
|
end
|
||||||
|
|
||||||
scenario "Destroy" do
|
scenario "Destroy" do
|
||||||
poll = create(:poll, :current)
|
poll = create(:poll)
|
||||||
booth = create(:poll_booth, polls: [poll])
|
booth = create(:poll_booth, polls: [poll])
|
||||||
officer = create(:poll_officer)
|
officer = create(:poll_officer)
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ require "rails_helper"
|
|||||||
describe "BudgetPolls", :with_frozen_time do
|
describe "BudgetPolls", :with_frozen_time do
|
||||||
let(:budget) { create(:budget, :balloting) }
|
let(:budget) { create(:budget, :balloting) }
|
||||||
let(:investment) { create(:budget_investment, :selected, budget: budget) }
|
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(:booth) { create(:poll_booth) }
|
||||||
let(:officer) { create(:poll_officer) }
|
let(:officer) { create(:poll_officer) }
|
||||||
let(:admin) { create(:administrator) }
|
let(:admin) { create(:administrator) }
|
||||||
|
|||||||
@@ -124,7 +124,7 @@ describe "Polls" do
|
|||||||
end
|
end
|
||||||
|
|
||||||
scenario "Edit poll is not allowed for current polls" do
|
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)
|
visit proposal_dashboard_polls_path(proposal)
|
||||||
|
|
||||||
@@ -232,7 +232,7 @@ describe "Polls" do
|
|||||||
end
|
end
|
||||||
|
|
||||||
scenario "View results available for current polls" do
|
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)
|
visit proposal_dashboard_polls_path(proposal)
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
require "rails_helper"
|
require "rails_helper"
|
||||||
|
|
||||||
describe "Voters" do
|
describe "Voters" do
|
||||||
let(:poll) { create(:poll, :current) }
|
let(:poll) { create(:poll) }
|
||||||
let(:booth) { create(:poll_booth) }
|
let(:booth) { create(:poll_booth) }
|
||||||
let(:officer) { create(:poll_officer) }
|
let(:officer) { create(:poll_officer) }
|
||||||
|
|
||||||
@@ -35,7 +35,7 @@ describe "Voters" do
|
|||||||
end
|
end
|
||||||
|
|
||||||
scenario "Cannot vote" do
|
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)
|
create(:poll_officer_assignment, officer: officer, poll: unvotable_poll, booth: booth)
|
||||||
|
|
||||||
set_officing_booth(booth)
|
set_officing_booth(booth)
|
||||||
@@ -49,7 +49,7 @@ describe "Voters" do
|
|||||||
end
|
end
|
||||||
|
|
||||||
scenario "Already voted" do
|
scenario "Already voted" do
|
||||||
poll2 = create(:poll, :current)
|
poll2 = create(:poll)
|
||||||
create(:poll_officer_assignment, officer: officer, poll: poll2, booth: booth)
|
create(:poll_officer_assignment, officer: officer, poll: poll2, booth: booth)
|
||||||
|
|
||||||
user = create(:user, :level_two)
|
user = create(:user, :level_two)
|
||||||
@@ -84,7 +84,7 @@ describe "Voters" do
|
|||||||
|
|
||||||
context "Polls displayed to officers" do
|
context "Polls displayed to officers" do
|
||||||
scenario "Display current polls assigned to a booth" 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)
|
create(:poll_officer_assignment, officer: officer, poll: poll, booth: booth)
|
||||||
|
|
||||||
set_officing_booth(booth)
|
set_officing_booth(booth)
|
||||||
@@ -96,7 +96,7 @@ describe "Voters" do
|
|||||||
end
|
end
|
||||||
|
|
||||||
scenario "Display polls that the user can vote" do
|
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)
|
create(:poll_officer_assignment, officer: officer, poll: votable_poll, booth: booth)
|
||||||
|
|
||||||
set_officing_booth(booth)
|
set_officing_booth(booth)
|
||||||
@@ -108,7 +108,7 @@ describe "Voters" do
|
|||||||
end
|
end
|
||||||
|
|
||||||
scenario "Display polls that the user cannot vote" do
|
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)
|
create(:poll_officer_assignment, officer: officer, poll: unvotable_poll, booth: booth)
|
||||||
|
|
||||||
set_officing_booth(booth)
|
set_officing_booth(booth)
|
||||||
@@ -132,8 +132,8 @@ describe "Voters" do
|
|||||||
end
|
end
|
||||||
|
|
||||||
scenario "Do not display polls from other booths" do
|
scenario "Do not display polls from other booths" do
|
||||||
poll1 = create(:poll, :current)
|
poll1 = create(:poll)
|
||||||
poll2 = create(:poll, :current)
|
poll2 = create(:poll)
|
||||||
|
|
||||||
booth1 = create(:poll_booth)
|
booth1 = create(:poll_booth)
|
||||||
booth2 = create(:poll_booth)
|
booth2 = create(:poll_booth)
|
||||||
|
|||||||
@@ -543,7 +543,7 @@ describe "Polls" do
|
|||||||
end
|
end
|
||||||
|
|
||||||
scenario "Don't show poll results and stats if is not expired" do
|
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)
|
user = create(:user)
|
||||||
|
|
||||||
login_as user
|
login_as user
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ require "rails_helper"
|
|||||||
|
|
||||||
describe "Voter" do
|
describe "Voter" do
|
||||||
context "Origin", :with_frozen_time do
|
context "Origin", :with_frozen_time do
|
||||||
let(:poll) { create(:poll, :current) }
|
let(:poll) { create(:poll) }
|
||||||
let(:question) { create(:poll_question, poll: poll) }
|
let(:question) { create(:poll_question, poll: poll) }
|
||||||
let(:booth) { create(:poll_booth) }
|
let(:booth) { create(:poll_booth) }
|
||||||
let(:officer) { create(:poll_officer) }
|
let(:officer) { create(:poll_officer) }
|
||||||
|
|||||||
Reference in New Issue
Block a user