diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml
index bcadd2a25..d359361a4 100644
--- a/.rubocop_todo.yml
+++ b/.rubocop_todo.yml
@@ -42,7 +42,6 @@ Layout/DotPosition:
- 'app/controllers/admin/poll/officer_assignments_controller.rb'
- 'app/controllers/admin/poll/polls_controller.rb'
- 'app/controllers/admin/poll/recounts_controller.rb'
- - 'app/controllers/officing/final_recounts_controller.rb'
- 'app/controllers/officing/residence_controller.rb'
- 'app/controllers/officing/results_controller.rb'
- 'app/models/poll/officer.rb'
@@ -191,7 +190,6 @@ Layout/MultilineMethodCallIndentation:
- 'app/controllers/admin/poll/officer_assignments_controller.rb'
- 'app/controllers/admin/poll/polls_controller.rb'
- 'app/controllers/admin/poll/recounts_controller.rb'
- - 'app/controllers/officing/final_recounts_controller.rb'
- 'app/controllers/officing/residence_controller.rb'
- 'app/controllers/officing/results_controller.rb'
- 'app/models/poll/officer.rb'
@@ -473,7 +471,6 @@ Style/ConditionalAssignment:
- 'app/controllers/admin/poll/questions_controller.rb'
- 'app/controllers/comments_controller.rb'
- 'app/controllers/management/spending_proposals_controller.rb'
- - 'app/controllers/officing/final_recounts_controller.rb'
- 'app/controllers/spending_proposals_controller.rb'
- 'app/controllers/verification/sms_controller.rb'
- 'lib/graph_ql/api_types_creator.rb'
diff --git a/app/controllers/officing/final_recounts_controller.rb b/app/controllers/officing/final_recounts_controller.rb
deleted file mode 100644
index 3efd6a682..000000000
--- a/app/controllers/officing/final_recounts_controller.rb
+++ /dev/null
@@ -1,49 +0,0 @@
-class Officing::FinalRecountsController < Officing::BaseController
- before_action :load_poll
- before_action :load_officer_assignment, only: :create
-
- def new
- @officer_assignments = ::Poll::OfficerAssignment.
- includes(:final_recounts, booth_assignment: [:booth]).
- joins(:booth_assignment).
- final.
- where(id: current_user.poll_officer.officer_assignment_ids).
- where("poll_booth_assignments.poll_id = ?", @poll.id).
- order(date: :asc)
-
- @final_recounts = @officer_assignments.select {|oa| oa.final_recounts.any?}.map(&:final_recounts).flatten
- end
-
- def create
- @final_recount = ::Poll::FinalRecount.find_or_initialize_by(booth_assignment_id: @officer_assignment.booth_assignment_id,
- date: final_recount_params[:date])
- @final_recount.officer_assignment_id = @officer_assignment.id
- @final_recount.count = final_recount_params[:count]
-
- if @final_recount.save
- msg = { notice: t("officing.final_recounts.flash.create") }
- else
- msg = { alert: t("officing.final_recounts.flash.error_create") }
- end
- redirect_to new_officing_poll_final_recount_path(@poll), msg
- end
-
- private
-
- def load_poll
- @poll = Poll.expired.find(params[:poll_id])
- end
-
- def load_officer_assignment
- @officer_assignment = current_user.poll_officer.
- officer_assignments.final.find_by(id: final_recount_params[:officer_assignment_id])
- if @officer_assignment.blank?
- redirect_to new_officing_poll_final_recount_path(@poll), alert: t("officing.final_recounts.flash.error_create")
- end
- end
-
- def final_recount_params
- params.permit(:officer_assignment_id, :count, :date)
- end
-
-end
diff --git a/app/views/officing/final_recounts/new.html.erb b/app/views/officing/final_recounts/new.html.erb
deleted file mode 100644
index 647bd31b4..000000000
--- a/app/views/officing/final_recounts/new.html.erb
+++ /dev/null
@@ -1,80 +0,0 @@
-<% if @officer_assignments.any? %>
-
<%= t("officing.final_recounts.new.title", poll: @poll.name) %>
-
- <%= form_tag(officing_poll_final_recounts_path(@poll), {id: "officer_assignment_form"}) do %>
-
-
-
- <%= select_tag :officer_assignment_id,
- booths_for_officer_select_options(@officer_assignments),
- { prompt: t("officing.final_recounts.new.select_booth"),
- label: false } %>
-
-
-
-
-
-
- <%= select_tag :date,
- poll_dates_select_options(@poll),
- { prompt: t("officing.final_recounts.new.select_date"),
- label: false } %>
-
-
-
-
-
-
- <%= text_field_tag :count, nil, placeholder: t("officing.final_recounts.new.count_placeholder") %>
-
-
-
-
-
- <%= submit_tag t("officing.final_recounts.new.submit"), class: "button expanded" %>
-
-
- <% end %>
-<% else %>
- <%= @poll.name %>
-
- <%= t("officing.final_recounts.new.not_allowed") %>
-
-<% end %>
-
-
-<% if @final_recounts.any? %>
-
- <%= t("officing.final_recounts.new.final_recount_list") %>
-
-
-
- | <%= t("officing.final_recounts.new.date") %> |
- <%= t("officing.final_recounts.new.booth") %> |
- <%= t("officing.final_recounts.new.count") %> |
- <%= t("officing.final_recounts.new.system_count") %> |
- |
-
-
- <% @final_recounts.each do |final_recount| %>
-
- |
- <%= l(final_recount.date.to_date, format: :long) %>
- |
-
- <%= final_recount.booth_assignment.booth.name %>
- |
-
- <%= final_recount.count %>
- |
-
- <%= system_recount_to_compare_with_final_recount final_recount %>
- |
-
- <%= link_to t("officing.final_recounts.new.add_results"), new_officing_poll_result_path(@poll, oa: final_recount.officer_assignment.id, d: l(final_recount.date.to_date) )%>
- |
-
- <% end %>
-
-
-<% end %>
\ No newline at end of file
diff --git a/config/routes.rb b/config/routes.rb
index a41e8d429..a02384ced 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -287,11 +287,11 @@ Rails.application.routes.draw do
end
resources :booths do
- get :available, on: :collection
+ get :available, on: :collection
resources :shifts do
get :search_officers, on: :collection
- end
+ end
end
resources :questions
@@ -420,7 +420,6 @@ Rails.application.routes.draw do
resources :polls, only: [:index] do
get :final, on: :collection
- resources :final_recounts, only: [:new, :create]
resources :results, only: [:new, :create, :index]
end
resource :residence, controller: "residence", only: [:new, :create]
diff --git a/spec/features/officing/final_recount_spec.rb b/spec/features/officing/final_recount_spec.rb
deleted file mode 100644
index ab1c39dc0..000000000
--- a/spec/features/officing/final_recount_spec.rb
+++ /dev/null
@@ -1,149 +0,0 @@
-require 'rails_helper'
-
-feature 'Officing Final Recount' do
-
- background do
- @poll_officer = create(:poll_officer)
- @officer_assignment = create(:poll_officer_assignment, :final, officer: @poll_officer)
- @poll = @officer_assignment.booth_assignment.poll
- @poll.update(ends_at: 1.day.ago)
- login_as(@poll_officer.user)
- end
-
- scenario 'Only polls where user is officer for final recounts are accessible' do
- regular_officer_assignment_1 = create(:poll_officer_assignment, officer: @poll_officer)
- regular_officer_assignment_2 = create(:poll_officer_assignment, officer: @poll_officer)
-
- not_allowed_poll_1 = create(:poll, :expired)
- not_allowed_poll_2 = regular_officer_assignment_1.booth_assignment.poll
- not_allowed_poll_2.update(ends_at: 1.day.ago)
- not_allowed_poll_3 = regular_officer_assignment_2.booth_assignment.poll
-
- visit root_path
- click_link 'Polling officers'
-
- expect(page).to have_content('Poll officing')
- within('#side_menu') do
- click_link 'Final recounts and results'
- end
-
- expect(page).to_not have_content(not_allowed_poll_1.name)
- expect(page).to_not have_content(not_allowed_poll_2.name)
- expect(page).to_not have_content(not_allowed_poll_3.name)
- expect(page).to have_content(@poll.name)
-
- visit new_officing_poll_final_recount_path(not_allowed_poll_1)
- expect(page).to have_content('You are allowed to add final recounts for this poll')
- end
-
- scenario 'Add final recount' do
- visit officing_root_path
-
- within('#side_menu') do
- click_link 'Final recounts and results'
- end
-
- within("#poll_#{@poll.id}") do
- expect(page).to have_content(@poll.name)
- click_link 'Add final recount'
- end
-
- expect(page).to_not have_content('Your recounts')
-
- booth_name = @officer_assignment.booth_assignment.booth.name
- date = I18n.l(@poll.starts_at.to_date, format: :long)
- select booth_name, from: 'officer_assignment_id'
- select date, from: 'date'
- fill_in :count, with: '33'
- click_button 'Save'
-
- expect(page).to have_content('Your final recounts')
-
- within("#poll_final_recount_#{@officer_assignment.booth_assignment.final_recounts.first.id}") do
- expect(page).to have_content(date)
- expect(page).to have_content(booth_name)
- expect(page).to have_content('33')
- end
- end
-
- scenario 'Edit final recount' do
- final_recount = create(:poll_final_recount,
- officer_assignment: @officer_assignment,
- booth_assignment: @officer_assignment.booth_assignment,
- date: @poll.starts_at,
- count: 100)
-
- booth_name = @officer_assignment.booth_assignment.booth.name
- date = I18n.l(final_recount.date.to_date, format: :long)
-
- visit new_officing_poll_final_recount_path(@poll)
-
- expect(page).to have_content('Your final recounts')
-
- within("#poll_final_recount_#{final_recount.id}") do
- expect(page).to have_content(date)
- expect(page).to have_content(booth_name)
- expect(page).to have_content('100')
- end
-
- select booth_name, from: 'officer_assignment_id'
- select date, from: 'date'
- fill_in :count, with: '42'
- click_button 'Save'
-
- expect(page).to have_content "Data added"
-
- within("#poll_final_recount_#{final_recount.id}") do
- expect(page).to have_content(date)
- expect(page).to have_content(booth_name)
- expect(page).to have_content('42')
- end
- expect(page).to_not have_content('100')
- end
-
- scenario 'Show final and system recounts to compare' do
- final_officer_assignment = create(:poll_officer_assignment, :final, officer: @poll_officer)
- poll = final_officer_assignment.booth_assignment.poll
- poll.update(ends_at: 1.day.ago)
- final_recount = create(:poll_final_recount,
- officer_assignment: final_officer_assignment,
- booth_assignment: final_officer_assignment.booth_assignment,
- date: 7.days.ago,
- count: 100)
- 33.times do
- create(:poll_voter, :valid_document,
- poll: poll,
- booth_assignment: final_officer_assignment.booth_assignment,
- created_at: final_recount.date)
- end
-
- visit new_officing_poll_final_recount_path(poll)
- within("#poll_final_recount_#{final_recount.id}") do
- expect(page).to have_content(I18n.l(final_recount.date.to_date, format: :long))
- expect(page).to have_content(final_officer_assignment.booth_assignment.booth.name)
- expect(page).to have_content('100')
- expect(page).to have_content('33')
- end
- end
-
- scenario "Show link to add results for same booth/date" do
- final_officer_assignment = create(:poll_officer_assignment, :final, officer: @poll_officer)
- poll = final_officer_assignment.booth_assignment.poll
- poll.update(ends_at: 1.day.ago)
- final_recount = create(:poll_final_recount,
- officer_assignment: final_officer_assignment,
- booth_assignment: final_officer_assignment.booth_assignment,
- date: 7.days.ago,
- count: 100)
- visit new_officing_poll_final_recount_path(poll)
- within("#poll_final_recount_#{final_recount.id}") do
- click_link "Add results"
- end
-
- expected_path = new_officing_poll_result_path(poll, oa: final_recount.officer_assignment.id, d: I18n.l(final_recount.date.to_date))
- expect(page).to have_current_path(expected_path)
- expect(page).to have_select('officer_assignment_id', selected: final_recount.booth_assignment.booth.name)
- expect(page).to have_select('date', selected: I18n.l(final_recount.date.to_date, format: :long))
- end
-
-end