removes obsolete code

This commit is contained in:
rgarcia
2017-08-04 20:44:18 +02:00
parent 0aba196ba2
commit 9181610de9
3 changed files with 0 additions and 159 deletions

View File

@@ -32,35 +32,6 @@ class Admin::Poll::OfficerAssignmentsController < Admin::BaseController
end
end
def create
@officer_assignment = ::Poll::OfficerAssignment.new(booth_assignment: @booth_assignment,
officer_id: create_params[:officer_id],
date: create_params[:date])
@officer_assignment.final = true if @officer_assignment.date > @booth_assignment.poll.ends_at.to_date
if @officer_assignment.save
notice = t("admin.poll_officer_assignments.flash.create")
else
notice = t("admin.poll_officer_assignments.flash.error_create")
end
redirect_params = { poll_id: create_params[:poll_id], officer_id: create_params[:officer_id] }
redirect_to by_officer_admin_poll_officer_assignments_path(redirect_params), notice: notice
end
def destroy
@officer_assignment = ::Poll::OfficerAssignment.includes(:booth_assignment).find(params[:id])
if @officer_assignment.destroy
notice = t("admin.poll_officer_assignments.flash.destroy")
else
notice = t("admin.poll_officer_assignments.flash.error_destroy")
end
redirect_params = { poll_id: @officer_assignment.poll_id, officer_id: @officer_assignment.officer_id }
redirect_to by_officer_admin_poll_officer_assignments_path(redirect_params), notice: notice
end
private
def officer_assignment_params

View File

@@ -5,35 +5,6 @@
<h2><%= @officer.name %> - <%= @officer.email %></h2>
<%= form_tag(admin_poll_officer_assignments_path(@poll), {id: "officer_assignment_form"}) do %>
<fieldset class="fieldset">
<legend><%= t("admin.poll_officer_assignments.by_officer.new_assignment") %></legend>
<div class="small-12 medium-4 column">
<label><%= t("admin.poll_officer_assignments.by_officer.date") %></label>
<%= select_tag :date,
poll_dates_select_options(@poll) + poll_final_recount_option(@poll),
{ prompt: t("admin.poll_officer_assignments.by_officer.select_date"),
label: false } %>
</div>
<div class="small-12 medium-4 column">
<label><%= t("admin.poll_officer_assignments.by_officer.booth") %></label>
<%= select_tag :booth_id,
poll_booths_select_options(@poll),
{ prompt: t("admin.poll_officer_assignments.by_officer.select_booth"),
label: false } %>
</div>
<div class="small-12 medium-4 column">
<%= hidden_field_tag :officer_id, @officer.id %>
<%= hidden_field_tag :poll_id, @poll.id %>
<%= submit_tag t("admin.poll_officer_assignments.by_officer.add_assignment"),
class: "button expanded hollow margin-top" %>
</div>
</fieldset>
<% end %>
<% if @officer_assignments.empty? %>
<div class="callout primary margin-top">
<%= t("admin.poll_officer_assignments.by_officer.no_assignments") %>
@@ -45,7 +16,6 @@
<tr>
<th><%= t("admin.poll_officer_assignments.by_officer.date") %></th>
<th><%= t("admin.poll_officer_assignments.by_officer.booth") %></th>
<th class="text-right"><%= t("admin.poll_officer_assignments.by_officer.assignment") %></th>
</tr>
</thead>
<tbody>
@@ -53,12 +23,6 @@
<tr id="<%= dom_id officer_assignment %>">
<td><%= officer_assignment.final? ? t('polls.final_date') : l(officer_assignment.date.to_date) %></td>
<td><%= booth_name_with_location(officer_assignment.booth_assignment.booth) %></td>
<td class="text-right">
<%= link_to t("admin.poll_officer_assignments.by_officer.remove_assignment"),
admin_poll_officer_assignment_path(@poll, officer_assignment),
method: :delete,
class: "button hollow alert" %>
</td>
</tr>
<% end %>
</tbody>
@@ -93,6 +57,3 @@
</tbody>
</table>
<% end %>

View File

@@ -1,91 +0,0 @@
require 'rails_helper'
feature 'Admin officer assignments in poll' do
background do
admin = create(:administrator)
login_as(admin.user)
end
scenario 'Assign officer to poll', :js do
booth_assignment = create(:poll_booth_assignment)
officer = create(:poll_officer)
visit admin_poll_path(booth_assignment.poll)
within('#poll-resources') do
click_link 'Officers (0)'
end
expect(page).to have_content 'There are no officers assigned to this poll'
fill_in 'search-officers', with: officer.name
click_button 'Search'
within('#search-officers-results') do
click_link 'Add shifts as officer'
end
expect(page).to have_content 'This user has no officing shifts in this poll'
expect(page).to have_content officer.name
expect(page).to have_content booth_assignment.poll.name
within('#officer_assignment_form') do
select I18n.l(booth_assignment.poll.ends_at.to_date, format: :long), from: 'date'
select "#{booth_assignment.booth.name} (#{booth_assignment.booth.location})", from: 'booth_id'
click_button 'Add shift'
end
expect(page).to have_content 'Officing shift added'
expect(page).to_not have_content 'This user has no officing shifts in this poll'
visit admin_poll_path(booth_assignment.poll)
within('#poll-resources') do
click_link 'Officers (1)'
end
expect(page).to_not have_content 'There are no officers in this poll'
expect(page).to have_content officer.name
expect(page).to have_content officer.email
end
scenario 'Remove officer assignment from poll' do
officer_assignment = create(:poll_officer_assignment)
poll = officer_assignment.booth_assignment.poll
booth = officer_assignment.booth_assignment.booth
officer = officer_assignment.officer
visit by_officer_admin_poll_officer_assignments_path(poll, officer_id: officer.id)
expect(page).to_not have_content 'This user has no officing shifts in this poll'
within("#poll_officer_assignment_#{officer_assignment.id}") do
expect(page).to have_content booth.name
click_link 'Remove'
end
expect(page).to have_content 'Officing shift removed'
expect(page).to have_content 'This user has no officing shifts in this poll'
end
scenario 'Index view shows recounts info for officer' do
booth_assignment = create(:poll_booth_assignment)
poll = booth_assignment.poll
officer = create(:poll_officer)
create(:poll_officer_assignment,
booth_assignment: booth_assignment,
officer: officer,
date: poll.starts_at)
final_officer_assignment = create(:poll_officer_assignment, :final,
booth_assignment: booth_assignment,
officer: officer,
date: poll.ends_at + 1.day)
create(:poll_final_recount,
booth_assignment: booth_assignment,
officer_assignment: final_officer_assignment,
date: poll.ends_at,
count: 9876)
visit by_officer_admin_poll_officer_assignments_path(poll, officer_id: officer.id)
within('#final_recount_list') { expect(page).to have_content('9876') }
end
end