Add trait to create a poll associated to a budget
This commit is contained in:
@@ -34,6 +34,10 @@ FactoryBot.define do
|
||||
trait :hidden do
|
||||
hidden_at { Time.current }
|
||||
end
|
||||
|
||||
trait :for_budget do
|
||||
association :budget
|
||||
end
|
||||
end
|
||||
|
||||
factory :poll_question, class: "Poll::Question" do
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
require "rails_helper"
|
||||
|
||||
describe "Poll budget ballot sheets" do
|
||||
let(:budget) { create(:budget) }
|
||||
let(:poll) { create(:poll, budget: budget, ends_at: 1.day.ago) }
|
||||
let(:poll) { create(:poll, :for_budget, ends_at: 1.day.ago) }
|
||||
let(:booth) { create(:poll_booth) }
|
||||
let(:poll_officer) { create(:poll_officer) }
|
||||
|
||||
|
||||
@@ -60,8 +60,7 @@ describe "Admin Budgets" do
|
||||
context "Show" do
|
||||
|
||||
scenario "Do not show questions section if the budget have a poll associated" do
|
||||
budget = create(:budget)
|
||||
poll = create(:poll, budget: budget)
|
||||
poll = create(:poll, :for_budget)
|
||||
|
||||
visit admin_poll_path(poll)
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ describe "Polls" do
|
||||
|
||||
scenario "Budget polls should not be listed" do
|
||||
poll = create(:poll)
|
||||
budget_poll = create(:poll, budget: create(:budget))
|
||||
budget_poll = create(:poll, :for_budget)
|
||||
|
||||
visit polls_path
|
||||
|
||||
@@ -22,7 +22,7 @@ describe "Polls" do
|
||||
login_as(create(:administrator).user)
|
||||
|
||||
poll = create(:poll)
|
||||
budget_poll = create(:poll, budget: create(:budget))
|
||||
budget_poll = create(:poll, :for_budget)
|
||||
|
||||
visit admin_polls_path
|
||||
|
||||
|
||||
@@ -8,10 +8,8 @@ describe "Poll Questions" do
|
||||
end
|
||||
|
||||
scenario "Do not display polls associated to a budget" do
|
||||
budget = create(:budget)
|
||||
|
||||
poll1 = create(:poll, name: "Citizen Proposal Poll")
|
||||
poll2 = create(:poll, budget: budget, name: "Participatory Budget Poll")
|
||||
poll2 = create(:poll, :for_budget, name: "Participatory Budget Poll")
|
||||
|
||||
visit admin_questions_path
|
||||
|
||||
|
||||
@@ -39,8 +39,7 @@ describe Poll::BallotSheet do
|
||||
|
||||
describe "#verify_ballots" do
|
||||
it "creates ballots for each document number" do
|
||||
budget = create(:budget)
|
||||
poll = create(:poll, budget: budget)
|
||||
poll = create(:poll, :for_budget)
|
||||
poll_ballot = create(:poll_ballot_sheet, poll: poll, data: "1,2,3;4,5,6")
|
||||
poll_ballot.verify_ballots
|
||||
|
||||
|
||||
@@ -346,11 +346,9 @@ describe Poll do
|
||||
describe "#not_budget" do
|
||||
|
||||
it "returns polls not associated to a budget" do
|
||||
budget = create(:budget)
|
||||
|
||||
poll1 = create(:poll)
|
||||
poll2 = create(:poll)
|
||||
poll3 = create(:poll, budget: budget)
|
||||
poll3 = create(:poll, :for_budget)
|
||||
|
||||
expect(Poll.not_budget).to include(poll1)
|
||||
expect(Poll.not_budget).to include(poll2)
|
||||
|
||||
Reference in New Issue
Block a user