Merge pull request #1885 from consul/chore/remove_final_recounts

Remove Poll Final Recounts, replace with Total Results
This commit is contained in:
BertoCQ
2017-09-20 23:00:03 +02:00
committed by GitHub
30 changed files with 69 additions and 201 deletions

View File

@@ -283,7 +283,6 @@ Lint/ParenthesesAsGroupedExpression:
# Cop supports --auto-correct. # Cop supports --auto-correct.
Lint/StringConversionInInterpolation: Lint/StringConversionInInterpolation:
Exclude: Exclude:
- 'app/models/poll/final_recount.rb'
- 'app/models/poll/null_result.rb' - 'app/models/poll/null_result.rb'
- 'app/models/poll/partial_result.rb' - 'app/models/poll/partial_result.rb'
- 'app/models/poll/white_result.rb' - 'app/models/poll/white_result.rb'

View File

@@ -15,7 +15,7 @@ class Admin::Poll::BoothAssignmentsController < Admin::Poll::BaseController
end end
def show def show
@booth_assignment = @poll.booth_assignments.includes(:final_recounts, :voters, @booth_assignment = @poll.booth_assignments.includes(:total_results, :voters,
officer_assignments: [officer: [:user]]).find(params[:id]) officer_assignments: [officer: [:user]]).find(params[:id])
@voters_by_date = @booth_assignment.voters.group_by {|v| v.created_at.to_date} @voters_by_date = @booth_assignment.voters.group_by {|v| v.created_at.to_date}
end end

View File

@@ -18,7 +18,7 @@ class Admin::Poll::OfficerAssignmentsController < Admin::Poll::BaseController
@officer = ::Poll::Officer.includes(:user).find(officer_assignment_params[:officer_id]) @officer = ::Poll::Officer.includes(:user).find(officer_assignment_params[:officer_id])
@officer_assignments = ::Poll::OfficerAssignment. @officer_assignments = ::Poll::OfficerAssignment.
joins(:booth_assignment). joins(:booth_assignment).
includes(:final_recounts, booth_assignment: :booth). includes(:total_results, booth_assignment: :booth).
where("officer_id = ? AND poll_booth_assignments.poll_id = ?", @officer.id, @poll.id). where("officer_id = ? AND poll_booth_assignments.poll_id = ?", @officer.id, @poll.id).
order(:date) order(:date)
end end

View File

@@ -3,7 +3,7 @@ class Admin::Poll::RecountsController < Admin::Poll::BaseController
def index def index
@booth_assignments = @poll.booth_assignments. @booth_assignments = @poll.booth_assignments.
includes(:booth, :final_recounts, :voters). includes(:booth, :total_results, :voters).
order("poll_booths.name"). order("poll_booths.name").
page(params[:page]).per(50) page(params[:page]).per(50)
end end

View File

@@ -1,13 +1,5 @@
module OfficingHelper module OfficingHelper
def officer_assignments_select_options(officer_assignments)
options = []
officer_assignments.each do |oa|
options << ["#{oa.booth_assignment.booth.name}: #{l(oa.date.to_date, format: :long)}", oa.id]
end
options_for_select(options)
end
def booths_for_officer_select_options(officer_assignments) def booths_for_officer_select_options(officer_assignments)
options = [] options = []
officer_assignments.each do |oa| officer_assignments.each do |oa|
@@ -17,10 +9,6 @@ module OfficingHelper
options_for_select(options, params[:oa]) options_for_select(options, params[:oa])
end end
def system_recount_to_compare_with_final_recount(final_recount)
final_recount.booth_assignment.voters.select {|v| v.created_at.to_date == final_recount.date}.size
end
def answer_result_value(question_id, answer_index) def answer_result_value(question_id, answer_index)
return nil if params.blank? return nil if params.blank?
return nil if params[:questions].blank? return nil if params[:questions].blank?

View File

@@ -1,7 +0,0 @@
module PollFinalRecountsHelper
def final_recount_for_date(final_recounts, date)
final_recounts.select {|f| f.date == date}.first
end
end

View File

@@ -1,7 +1,7 @@
module PollRecountsHelper module PollRecountsHelper
def booth_assignment_sum_final_recounts(ba) def total_recounts_by_booth(booth_assignment)
ba.final_recounts.any? ? ba.final_recounts.to_a.sum(&:count) : nil booth_assignment.total_results.any? ? booth_assignment.total_results.to_a.sum(&:amount) : nil
end end
end end

View File

@@ -28,11 +28,6 @@ module PollsHelper
options_for_select(options, params[:d]) options_for_select(options, params[:d])
end end
def poll_final_recount_option(poll)
final_date = poll.ends_at.to_date + 1.day
options_for_select([[I18n.t("polls.final_date"), l(final_date)]])
end
def poll_booths_select_options(poll) def poll_booths_select_options(poll)
options = [] options = []
poll.booths.each do |booth| poll.booths.each do |booth|
@@ -46,4 +41,4 @@ module PollsHelper
booth.name + location booth.name + location
end end
end end

View File

@@ -4,7 +4,6 @@ class Poll
belongs_to :poll belongs_to :poll
has_many :officer_assignments, class_name: "Poll::OfficerAssignment", dependent: :destroy has_many :officer_assignments, class_name: "Poll::OfficerAssignment", dependent: :destroy
has_many :final_recounts, class_name: "Poll::FinalRecount", dependent: :destroy
has_many :officers, through: :officer_assignments has_many :officers, through: :officer_assignments
has_many :voters has_many :voters
has_many :partial_results has_many :partial_results

View File

@@ -1,19 +0,0 @@
class Poll
class FinalRecount < ActiveRecord::Base
belongs_to :booth_assignment, class_name: "Poll::BoothAssignment"
belongs_to :officer_assignment, class_name: "Poll::OfficerAssignment"
validates :booth_assignment_id, presence: true
validates :date, presence: true, uniqueness: {scope: :booth_assignment_id}
validates :count, presence: true, numericality: {only_integer: true}
before_save :update_logs
def update_logs
if count_changed? && count_was.present?
self.count_log += ":#{count_was.to_s}"
self.officer_assignment_id_log += ":#{officer_assignment_id_was.to_s}"
end
end
end
end

View File

@@ -2,8 +2,10 @@ class Poll
class OfficerAssignment < ActiveRecord::Base class OfficerAssignment < ActiveRecord::Base
belongs_to :officer belongs_to :officer
belongs_to :booth_assignment belongs_to :booth_assignment
has_many :final_recounts
has_many :partial_results has_many :partial_results
has_many :white_results
has_many :null_results
has_many :total_results
has_many :voters has_many :voters
validates :officer_id, presence: true validates :officer_id, presence: true

View File

@@ -49,18 +49,18 @@
<thead> <thead>
<tr> <tr>
<th><%= t("admin.poll_booth_assignments.show.date") %></th> <th><%= t("admin.poll_booth_assignments.show.date") %></th>
<th class="text-center"><%= t("admin.poll_booth_assignments.show.count_final") %></th> <th class="text-center"><%= t("admin.poll_booth_assignments.show.total_recount") %></th>
<th class="text-center"><%= t("admin.poll_booth_assignments.show.count_by_system") %></th> <th class="text-center"><%= t("admin.poll_booth_assignments.show.count_by_system") %></th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<% (@poll.starts_at.to_date..@poll.ends_at.to_date).each do |voting_date| %> <% (@poll.starts_at.to_date..@poll.ends_at.to_date).each do |voting_date| %>
<% final_recount = final_recount_for_date(@booth_assignment.final_recounts, voting_date) %> <% total_recount = @booth_assignment.total_results.where(date: voting_date).first %>
<% system_count = @voters_by_date[voting_date].present? ? @voters_by_date[voting_date].size : 0 %> <% system_count = @voters_by_date[voting_date].present? ? @voters_by_date[voting_date].size : 0 %>
<tr id="recounting_<%= voting_date.strftime('%Y%m%d') %>"> <tr id="recounting_<%= voting_date.strftime('%Y%m%d') %>">
<td><%= l voting_date %></td> <td><%= l voting_date %></td>
<% if final_recount.present? %> <% if total_recount.present? %>
<td class="text-center <%= 'count-error' if final_recount.count != system_count %>" title="<%= final_recount.officer_assignment.officer.name %>"><%= final_recount.count %></td> <td class="text-center <%= 'count-error' if total_recount.amount != system_count %>" title="<%= total_recount.officer_assignment.officer.name %>"><%= total_recount.amount %></td>
<% else %> <% else %>
<td class="text-center" title=""> - </td> <td class="text-center" title=""> - </td>
<% end %> <% end %>

View File

@@ -27,27 +27,24 @@
<% end %> <% end %>
</tbody> </tbody>
</table> </table>
<% end %>
<% final_officer_assignments = @officer_assignments.select{|oa| oa.final == true} %> <h3><%= t("admin.poll_officer_assignments.by_officer.total_recounts") %></h3>
<% if final_officer_assignments.any? %> <table id="total_recount_list" class="fixed">
<h3><%= t("admin.poll_officer_assignments.by_officer.final_recounts") %></h3>
<table id="final_recount_list" class="fixed">
<thead> <thead>
<tr> <tr>
<th><%= t("admin.poll_officer_assignments.by_officer.date") %></th> <th><%= t("admin.poll_officer_assignments.by_officer.date") %></th>
<th><%= t("admin.poll_officer_assignments.by_officer.booth") %></th> <th><%= t("admin.poll_officer_assignments.by_officer.booth") %></th>
<th class="text-right"><%= t("admin.poll_officer_assignments.by_officer.final_recount") %></th> <th class="text-right"><%= t("admin.poll_officer_assignments.by_officer.total_recount") %></th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<% final_officer_assignments.each do |officer_assignment| %> <% @officer_assignments.each do |officer_assignment| %>
<tr id="final_recount_<%= officer_assignment.date.to_date.strftime('%Y%m%d') %>"> <tr id="total_recount_<%= officer_assignment.date.to_date.strftime('%Y%m%d') %>">
<td><%= l(officer_assignment.date.to_date) %></td> <td><%= l(officer_assignment.date.to_date) %></td>
<td><%= booth_name_with_location(officer_assignment.booth_assignment.booth) %></td> <td><%= booth_name_with_location(officer_assignment.booth_assignment.booth) %></td>
<td class="text-right"> <td class="text-right">
<% if officer_assignment.final_recounts.any? %> <% if officer_assignment.total_results.any? %>
<%= officer_assignment.final_recounts.to_a.sum(&:count) %> <%= officer_assignment.total_results.to_a.sum(&:amount) %>
<% else %> <% else %>
<span>-</span> <span>-</span>
<% end %> <% end %>

View File

@@ -12,12 +12,12 @@
<table class="fixed margin"> <table class="fixed margin">
<thead> <thead>
<th><%= t("admin.recounts.index.table_booth_name") %></th> <th><%= t("admin.recounts.index.table_booth_name") %></th>
<th class="text-center"><%= t("admin.recounts.index.table_final_recount") %></th> <th class="text-center"><%= t("admin.recounts.index.table_total_recount") %></th>
<th class="text-center"><%= t("admin.recounts.index.table_system_count") %></th> <th class="text-center"><%= t("admin.recounts.index.table_system_count") %></th>
</thead> </thead>
<tbody> <tbody>
<% @booth_assignments.each do |booth_assignment| %> <% @booth_assignments.each do |booth_assignment| %>
<% final_recount = booth_assignment_sum_final_recounts(booth_assignment) %> <% total_recounts = total_recounts_by_booth(booth_assignment) %>
<% system_count = booth_assignment.voters.size %> <% system_count = booth_assignment.voters.size %>
<tr id="<%= dom_id(booth_assignment) %>_recounts" class="booth_recounts"> <tr id="<%= dom_id(booth_assignment) %>_recounts" class="booth_recounts">
<td> <td>
@@ -25,9 +25,9 @@
<%= link_to booth_assignment.booth.name, admin_poll_booth_assignment_path(@poll, booth_assignment, anchor: 'tab-recounts') %> <%= link_to booth_assignment.booth.name, admin_poll_booth_assignment_path(@poll, booth_assignment, anchor: 'tab-recounts') %>
</strong> </strong>
</td> </td>
<td class="text-center <%= 'count-error' if final_recount.to_i != system_count %>"> <td class="text-center <%= 'count-error' if total_recounts.to_i != system_count %>">
<% if final_recount.present? %> <% if total_recounts.present? %>
<strong><%= final_recount %></strong> <strong><%= total_recounts %></strong>
<% else %> <% else %>
<span>-</span> <span>-</span>
<% end %> <% end %>

View File

@@ -8,10 +8,10 @@
<% end %> <% end %>
</li> </li>
<li <%= "class=active" if ["final_recounts", "results"].include?(controller_name) || (controller_name == "polls" && action_name == "final") %>> <li <%= "class=active" if ["results"].include?(controller_name) || (controller_name == "polls" && action_name == "final") %>>
<%= link_to final_officing_polls_path do %> <%= link_to final_officing_polls_path do %>
<span class="icon-user"></span> <span class="icon-user"></span>
<%= t("officing.menu.final_recounts") %> <%= t("officing.menu.total_recounts") %>
<% end %> <% end %>
</li> </li>
</ul> </ul>

View File

@@ -494,8 +494,8 @@ en:
booth: "Booth" booth: "Booth"
assignments: "Officing shifts in this poll" assignments: "Officing shifts in this poll"
no_assignments: "This user has no officing shifts in this poll." no_assignments: "This user has no officing shifts in this poll."
final_recounts: "Final recounts" total_recounts: "Total recounts"
final_recount: "Final recount (by officer)" total_recount: "Total recount (by officer)"
poll_shifts: poll_shifts:
new: new:
add_shift: "Add shift" add_shift: "Add shift"
@@ -531,7 +531,7 @@ en:
recounts: "Recounts" recounts: "Recounts"
recounts_list: "Recount list for this booth" recounts_list: "Recount list for this booth"
date: "Date" date: "Date"
count_final: "Final recount (by officer)" total_recount: "Total recount (by officer)"
count_by_system: "Votes (automatic)" count_by_system: "Votes (automatic)"
index: index:
booths_title: "List of booths" booths_title: "List of booths"
@@ -604,7 +604,7 @@ en:
title: "Recounts" title: "Recounts"
no_recounts: "There is nothing to be recounted" no_recounts: "There is nothing to be recounted"
table_booth_name: "Booth" table_booth_name: "Booth"
table_final_recount: "Final recount (by officer)" table_total_recount: "Total recount (by officer)"
table_system_count: "Votes (automatic)" table_system_count: "Votes (automatic)"
results: results:
index: index:

View File

@@ -9,7 +9,7 @@ en:
info: Here you can validate user documents and store voting results info: Here you can validate user documents and store voting results
menu: menu:
voters: Validate document voters: Validate document
final_recounts: Final recounts and results total_recounts: Total recounts and results
polls: polls:
final: final:
title: Polls ready for final recounting title: Polls ready for final recounting

View File

@@ -494,8 +494,8 @@ es:
booth: "Urna" booth: "Urna"
assignments: "Turnos como presidente de mesa en esta votación" assignments: "Turnos como presidente de mesa en esta votación"
no_assignments: "No tiene turnos como presidente de mesa en esta votación." no_assignments: "No tiene turnos como presidente de mesa en esta votación."
final_recounts: "Recuentos finales" total_recounts: "Recuentos totales"
final_recount: "Recuento final (presidente de mesa)" total_recount: "Recuento total (presidente de mesa)"
poll_shifts: poll_shifts:
new: new:
add_shift: "Añadir turno" add_shift: "Añadir turno"
@@ -531,7 +531,7 @@ es:
recounts: "Recuentos" recounts: "Recuentos"
recounts_list: "Lista de recuentos de esta urna" recounts_list: "Lista de recuentos de esta urna"
date: "Fecha" date: "Fecha"
count_final: "Recuento final (presidente de mesa)" total_recount: "Recuento total (presidente de mesa)"
count_by_system: "Votos (automático)" count_by_system: "Votos (automático)"
index: index:
booths_title: "Listado de urnas asignadas" booths_title: "Listado de urnas asignadas"
@@ -604,7 +604,7 @@ es:
title: "Recuentos" title: "Recuentos"
no_recounts: "No hay nada de lo que hacer recuento" no_recounts: "No hay nada de lo que hacer recuento"
table_booth_name: "Urna" table_booth_name: "Urna"
table_final_recount: "Recuento final (presidente de mesa)" table_total_recount: "Recuento total (presidente de mesa)"
table_system_count: "Votos (automático)" table_system_count: "Votos (automático)"
results: results:
index: index:

View File

@@ -9,7 +9,7 @@ es:
info: Aquí puedes validar documentos de ciudadanos y guardar los resultados de las urnas info: Aquí puedes validar documentos de ciudadanos y guardar los resultados de las urnas
menu: menu:
voters: "Validar documento y votar" voters: "Validar documento y votar"
final_recounts: "Recuento final y escrutinio" total_recounts: "Recuento total y escrutinio"
polls: polls:
final: final:
title: "Listado de votaciones finalizadas" title: "Listado de votaciones finalizadas"

View File

@@ -301,8 +301,8 @@ fr:
no_assignments: "Cet utilisateur n'a pas d'affectation pour ce vote." no_assignments: "Cet utilisateur n'a pas d'affectation pour ce vote."
recounts: "Dépouillement journalier" recounts: "Dépouillement journalier"
recount: "Dépouillement journalier (par président)" recount: "Dépouillement journalier (par président)"
final_recounts: "Dépouillement final" total_recounts: "Dépouillement final"
final_recount: "Dépouillement final (par président)" total_recount: "Dépouillement final (par président)"
poll_booth_assignments: poll_booth_assignments:
flash: flash:
destroy: "Ce bureau de vote n'est plus affecté" destroy: "Ce bureau de vote n'est plus affecté"
@@ -319,7 +319,7 @@ fr:
no_recounts: "Il n'y a pas encore de dépouillements journaliers pour ce bureau de vote." no_recounts: "Il n'y a pas encore de dépouillements journaliers pour ce bureau de vote."
date: "Date" date: "Date"
count_by_officer: "Dépouillement journalier (par président)" count_by_officer: "Dépouillement journalier (par président)"
count_final: "Dépouillement final (par président)" total_count: "Dépouillement final (par président)"
count_by_system: "Votes (automatique)" count_by_system: "Votes (automatique)"
index: index:
booths_title: "Liste des bureaux de vote" booths_title: "Liste des bureaux de vote"
@@ -391,7 +391,7 @@ fr:
no_recounts: "Il n'y a rien à dépouiller" no_recounts: "Il n'y a rien à dépouiller"
table_booth_name: "Bureau de vote" table_booth_name: "Bureau de vote"
table_recounts: "Accumulation des dépouillements journaliers (par président)" table_recounts: "Accumulation des dépouillements journaliers (par président)"
table_final_recount: "Dépouillement final (par président)" table_total_recount: "Dépouillement final (par président)"
table_system_count: "Votes (automatique)" table_system_count: "Votes (automatique)"
results: results:
index: index:

View File

@@ -10,7 +10,7 @@ fr:
menu: menu:
voters: "Valider un document" voters: "Valider un document"
recounts: "Enregistrer le dépouillement" recounts: "Enregistrer le dépouillement"
final_recounts: "Dépouillements finaux et résultats" total_recounts: "Dépouillements finaux et résultats"
polls: polls:
index: index:
title: "Liste des votes" title: "Liste des votes"
@@ -38,23 +38,6 @@ fr:
recount_list: "Vos dépouillements" recount_list: "Vos dépouillements"
booth: "Urne" booth: "Urne"
date: "Date" date: "Date"
final_recounts:
flash:
create: "Données ajoutées"
error_create: "Décompte final NON ajouté. Erreur dans les données."
new:
title: "%{poll} - Ajouter le dépouillement final"
not_allowed: "Vous n'êtes pas autorisés à ajouter les dépouillements finaux pour ce vote"
booth: "Bureau de vote"
date: "Date"
select_booth: "Sélectionner un bureau de vote"
select_date: "Sélectionner une date"
count: "Décompte final des votes"
count_placeholder: "Décompte final des votes"
submit: "Sauvegarder"
final_recount_list: "Vos dépouillements finaux"
system_count: "Dépouillement par le système"
add_results: "Ajouter les résultats"
results: results:
flash: flash:
create: "Résultats sauvegardés" create: "Résultats sauvegardés"

View File

@@ -301,8 +301,8 @@ nl:
no_assignments: "This user has no officing shifts in this poll." no_assignments: "This user has no officing shifts in this poll."
recounts: "Daily recounts" recounts: "Daily recounts"
recount: "Daily recount (by officer)" recount: "Daily recount (by officer)"
final_recounts: "Final recounts" total_recounts: "Final recounts"
final_recount: "Final recount (by officer)" total_recount: "Final recount (by officer)"
poll_booth_assignments: poll_booth_assignments:
flash: flash:
destroy: "Booth not assigned anymore" destroy: "Booth not assigned anymore"
@@ -319,7 +319,7 @@ nl:
no_recounts: "There are not daily recounts of this booth yet" no_recounts: "There are not daily recounts of this booth yet"
date: "Date" date: "Date"
count_by_officer: "Daily recount (by officer)" count_by_officer: "Daily recount (by officer)"
count_final: "Final recount (by officer)" total_count: "Final recount (by officer)"
count_by_system: "Votes (automatic)" count_by_system: "Votes (automatic)"
index: index:
booths_title: "List of booths" booths_title: "List of booths"
@@ -391,7 +391,7 @@ nl:
no_recounts: "There is nothing to be recounted" no_recounts: "There is nothing to be recounted"
table_booth_name: "Booth" table_booth_name: "Booth"
table_recounts: "Accumulated daily recounts (by officer)" table_recounts: "Accumulated daily recounts (by officer)"
table_final_recount: "Final recount (by officer)" table_total_recount: "Final recount (by officer)"
table_system_count: "Votes (automatic)" table_system_count: "Votes (automatic)"
results: results:
index: index:

View File

@@ -10,7 +10,7 @@ nl:
menu: menu:
voters: Validate document voters: Validate document
recounts: Store recount recounts: Store recount
final_recounts: Final recounts and results total_recounts: Total recounts and results
polls: polls:
index: index:
title: Poll list title: Poll list
@@ -38,23 +38,6 @@ nl:
recount_list: "Your recounts" recount_list: "Your recounts"
booth: "Booth" booth: "Booth"
date: "Date" date: "Date"
final_recounts:
flash:
create: "Data added"
error_create: "Final counts NOT added. Error in data."
new:
title: "%{poll} - Add final recount"
not_allowed: "You are allowed to add final recounts for this poll"
booth: "Booth"
date: "Date"
select_booth: "Select booth"
select_date: "Select date"
count: "Final vote count"
count_placeholder: "Final vote count"
submit: Save
final_recount_list: "Your final recounts"
system_count: "System recount"
add_results: "Add results"
results: results:
flash: flash:
create: "Results saved" create: "Results saved"

View File

@@ -0,0 +1,11 @@
class RemovePollFinalRecounts < ActiveRecord::Migration
def change
remove_index :poll_final_recounts, column: :booth_assignment_id
remove_index :poll_final_recounts, column: :officer_assignment_id
remove_foreign_key :poll_final_recounts, column: "booth_assignment_id"
remove_foreign_key :poll_final_recounts, column: "officer_assignment_id"
drop_table :poll_final_recounts
end
end

View File

@@ -11,7 +11,7 @@
# #
# It's strongly recommended that you check this file into your version control system. # It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 20170914154743) do ActiveRecord::Schema.define(version: 20170918231410) do
# These are extensions that must be enabled in order to support this database # These are extensions that must be enabled in order to support this database
enable_extension "plpgsql" enable_extension "plpgsql"
@@ -586,20 +586,6 @@ ActiveRecord::Schema.define(version: 20170914154743) do
t.string "location" t.string "location"
end end
create_table "poll_final_recounts", force: :cascade do |t|
t.integer "booth_assignment_id"
t.integer "officer_assignment_id"
t.integer "count"
t.text "count_log", default: ""
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.text "officer_assignment_id_log", default: ""
t.date "date", null: false
end
add_index "poll_final_recounts", ["booth_assignment_id"], name: "index_poll_final_recounts_on_booth_assignment_id", using: :btree
add_index "poll_final_recounts", ["officer_assignment_id"], name: "index_poll_final_recounts_on_officer_assignment_id", using: :btree
create_table "poll_null_results", force: :cascade do |t| create_table "poll_null_results", force: :cascade do |t|
t.integer "author_id" t.integer "author_id"
t.integer "amount" t.integer "amount"
@@ -1101,8 +1087,6 @@ ActiveRecord::Schema.define(version: 20170914154743) do
add_foreign_key "organizations", "users" add_foreign_key "organizations", "users"
add_foreign_key "poll_answers", "poll_questions", column: "question_id" add_foreign_key "poll_answers", "poll_questions", column: "question_id"
add_foreign_key "poll_booth_assignments", "polls" add_foreign_key "poll_booth_assignments", "polls"
add_foreign_key "poll_final_recounts", "poll_booth_assignments", column: "booth_assignment_id"
add_foreign_key "poll_final_recounts", "poll_officer_assignments", column: "officer_assignment_id"
add_foreign_key "poll_null_results", "poll_booth_assignments", column: "booth_assignment_id" add_foreign_key "poll_null_results", "poll_booth_assignments", column: "booth_assignment_id"
add_foreign_key "poll_null_results", "poll_officer_assignments", column: "officer_assignment_id" add_foreign_key "poll_null_results", "poll_officer_assignments", column: "officer_assignment_id"
add_foreign_key "poll_officer_assignments", "poll_booth_assignments", column: "booth_assignment_id" add_foreign_key "poll_officer_assignments", "poll_booth_assignments", column: "booth_assignment_id"

View File

@@ -507,13 +507,6 @@ FactoryGirl.define do
date Date.current date Date.current
end end
factory :poll_final_recount, class: 'Poll::FinalRecount' do
association :officer_assignment, factory: [:poll_officer_assignment, :final]
association :booth_assignment, factory: :poll_booth_assignment
count (1..100).to_a.sample
date (1.month.ago.to_datetime..1.month.from_now.to_datetime).to_a.sample
end
factory :poll_voter, class: 'Poll::Voter' do factory :poll_voter, class: 'Poll::Voter' do
poll poll
association :user, :level_two association :user, :level_two

View File

@@ -97,11 +97,11 @@ feature 'Admin booths assignments' do
officer_assignment_2 = create(:poll_officer_assignment, booth_assignment: booth_assignment, date: poll.ends_at) officer_assignment_2 = create(:poll_officer_assignment, booth_assignment: booth_assignment, date: poll.ends_at)
final_officer_assignment = create(:poll_officer_assignment, :final, booth_assignment: booth_assignment, date: poll.ends_at) final_officer_assignment = create(:poll_officer_assignment, :final, booth_assignment: booth_assignment, date: poll.ends_at)
final_recount = create(:poll_final_recount, total_recount = create(:poll_total_result,
booth_assignment: booth_assignment, booth_assignment: booth_assignment,
officer_assignment: final_officer_assignment, officer_assignment: final_officer_assignment,
date: final_officer_assignment.date, date: final_officer_assignment.date,
count: 5678) amount: 5678)
booth_assignment_2 = create(:poll_booth_assignment, poll: poll) booth_assignment_2 = create(:poll_booth_assignment, poll: poll)
@@ -112,8 +112,8 @@ feature 'Admin booths assignments' do
click_link 'Recounts' click_link 'Recounts'
within('#recounts_list') do within('#recounts_list') do
within("#recounting_#{final_recount.date.strftime('%Y%m%d')}") do within("#recounting_#{total_recount.date.strftime('%Y%m%d')}") do
expect(page).to have_content final_recount.count expect(page).to have_content total_recount.amount
end end
end end
end end

View File

@@ -249,18 +249,18 @@ feature 'Admin polls' do
booth_assignment_final_recounted = create(:poll_booth_assignment, poll: poll) booth_assignment_final_recounted = create(:poll_booth_assignment, poll: poll)
3.times do |i| 3.times do |i|
create(:poll_final_recount, create(:poll_total_result,
booth_assignment: booth_assignment, booth_assignment: booth_assignment,
date: poll.starts_at + i.days, date: poll.starts_at + i.days,
count: 21) amount: 21)
end end
2.times { create(:poll_voter, booth_assignment: booth_assignment_final_recounted) } 2.times { create(:poll_voter, booth_assignment: booth_assignment_final_recounted) }
create(:poll_final_recount, create(:poll_total_result,
booth_assignment: booth_assignment_final_recounted, booth_assignment: booth_assignment_final_recounted,
date: poll.ends_at, date: poll.ends_at,
count: 55555) amount: 55555)
visit admin_poll_path(poll) visit admin_poll_path(poll)

View File

@@ -26,7 +26,7 @@ feature 'Officing Results' do
expect(page).to have_content('Poll officing') expect(page).to have_content('Poll officing')
within('#side_menu') do within('#side_menu') do
click_link 'Final recounts and results' click_link 'Total recounts and results'
end end
expect(page).to_not have_content(not_allowed_poll_1.name) expect(page).to_not have_content(not_allowed_poll_1.name)
@@ -42,7 +42,7 @@ feature 'Officing Results' do
visit officing_root_path visit officing_root_path
within('#side_menu') do within('#side_menu') do
click_link 'Final recounts and results' click_link 'Total recounts and results'
end end
within("#poll_#{@poll.id}") do within("#poll_#{@poll.id}") do

View File

@@ -1,40 +0,0 @@
require 'rails_helper'
describe :final_recount do
it "should update count_log if count changes" do
final_recount = create(:poll_final_recount, count: 33)
expect(final_recount.count_log).to eq("")
final_recount.count = 33
final_recount.save
final_recount.count = 32
final_recount.save
final_recount.count = 34
final_recount.save
expect(final_recount.count_log).to eq(":33:32")
end
it "should update officer_assignment_id_log if count changes" do
final_recount = create(:poll_final_recount, count: 33)
expect(final_recount.count_log).to eq("")
final_recount.count = 33
final_recount.officer_assignment = create(:poll_officer_assignment, id: 111)
final_recount.save
final_recount.count = 32
final_recount.officer_assignment = create(:poll_officer_assignment, id: 112)
final_recount.save
final_recount.count = 34
final_recount.officer_assignment = create(:poll_officer_assignment, id: 113)
final_recount.save
expect(final_recount.officer_assignment_id_log).to eq(":111:112")
end
end