Add test case for adding budget poll results
While writing the test, we noticed it didn't work because the labels weren't correctly generated, so we're fixing them as well.
This commit is contained in:
@@ -2,12 +2,12 @@
|
||||
<h2><%= t("officing.poll_budgets.new.title", poll_budget: @poll.name) %></h2>
|
||||
|
||||
<%= form_tag(officing_poll_ballot_sheets_path(@poll)) do %>
|
||||
<label><%= t("officing.poll_budgets.new.booth") %></label>
|
||||
<%= label_tag :officer_assignment_id, t("officing.poll_budgets.new.booth") %>
|
||||
<%= select_tag :officer_assignment_id,
|
||||
booths_for_officer_select_options(@officer_assignments),
|
||||
{ prompt: t("officing.poll_budgets.new.select_booth") } %>
|
||||
|
||||
<label><%= t("officing.poll_budgets.new.csv_data") %></label>
|
||||
<%= label_tag :data, t("officing.poll_budgets.new.csv_data") %>
|
||||
<%= text_area_tag :data, nil, rows: 10 %>
|
||||
|
||||
<%= submit_tag t("officing.poll_budgets.new.submit"), class: "button" %>
|
||||
|
||||
46
spec/system/officing/ballot_sheets_spec.rb
Normal file
46
spec/system/officing/ballot_sheets_spec.rb
Normal file
@@ -0,0 +1,46 @@
|
||||
require "rails_helper"
|
||||
|
||||
describe "Officing ballot sheets" do
|
||||
let(:budget) { create(:budget, :reviewing_ballots) }
|
||||
let(:heading) { create(:budget_heading, budget: budget, price: 300) }
|
||||
let(:poll) { create(:poll, name: "Latest budget poll", budget: budget, ends_at: Date.current) }
|
||||
let(:booth) { create(:poll_booth, name: "The only booth") }
|
||||
let(:officer) { create(:poll_officer) }
|
||||
let!(:admin) { create(:administrator).user }
|
||||
|
||||
scenario "Create a ballot sheet for a budget poll" do
|
||||
create(:poll_officer_assignment, officer: officer, poll: poll, booth: booth)
|
||||
create(:poll_shift, :recount_scrutiny_task, officer: officer, booth: booth, date: Date.current)
|
||||
|
||||
titles = %w[First Second Third Fourth]
|
||||
investments = 4.times.map do |n|
|
||||
create(:budget_investment, :selected, title: titles[n], heading: heading, price: 100)
|
||||
end
|
||||
|
||||
login_as(officer.user)
|
||||
visit officing_root_path
|
||||
click_link "Total recounts and results"
|
||||
within("tr", text: "Latest budget poll") { click_link "Add results" }
|
||||
|
||||
select "The only booth", from: "Booth"
|
||||
fill_in "CSV data", with: "#{investments[0..1].map(&:id).join(",")};#{investments[1..2].map(&:id).join(",")}"
|
||||
click_button "Save"
|
||||
|
||||
expect(page).to have_content "Creation date"
|
||||
expect(page).to have_content "CSV data"
|
||||
|
||||
logout
|
||||
login_as(admin)
|
||||
visit admin_budget_path(budget)
|
||||
click_button "Calculate Winner Investments"
|
||||
|
||||
expect(page).to have_content "Winners being calculated"
|
||||
|
||||
visit budget_results_path(budget)
|
||||
|
||||
within("tr", text: "Second") { expect(page).to have_content("2") }
|
||||
within("tr", text: "First") { expect(page).to have_content("1") }
|
||||
within("tr", text: "Third") { expect(page).to have_content("1") }
|
||||
expect(page).not_to have_content "Fourth"
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user