Merge pull request #1418 from consul/poll-show-breaking

Break admin's poll show view
This commit is contained in:
Enrique García
2017-02-14 15:33:55 +01:00
committed by GitHub
33 changed files with 600 additions and 497 deletions

View File

@@ -1,31 +1,44 @@
class Admin::Poll::BoothAssignmentsController < Admin::BaseController
before_action :load_poll, except: [:create, :destroy]
def index
@booth_assignments = @poll.booth_assignments.includes(:booth)
end
def search_booths
load_search
@booths = ::Poll::Booth.search(@search)
respond_to do |format|
format.js
end
end
def show
@booth_assignment = @poll.booth_assignments.includes(:recounts, :final_recounts, :voters, officer_assignments: [officer: [:user]]).find(params[:id])
@voters_by_date = @booth_assignment.voters.group_by {|v| v.created_at.to_date}
end
def create
@booth_assignment = ::Poll::BoothAssignment.new(poll_id: booth_assignment_params[:poll], booth_id: booth_assignment_params[:booth])
if @booth_assignment.save
notice = t("admin.booth_assignments.flash.create")
notice = t("admin.poll_booth_assignments.flash.create")
else
notice = t("admin.booth_assignments.flash.error_create")
notice = t("admin.poll_booth_assignments.flash.error_create")
end
redirect_to admin_poll_path(@booth_assignment.poll_id, anchor: 'tab-booths'), notice: notice
redirect_to admin_poll_booth_assignments_path(@booth_assignment.poll_id), notice: notice
end
def destroy
@booth_assignment = ::Poll::BoothAssignment.find(params[:id])
if @booth_assignment.destroy
notice = t("admin.booth_assignments.flash.destroy")
notice = t("admin.poll_booth_assignments.flash.destroy")
else
notice = t("admin.booth_assignments.flash.error_destroy")
notice = t("admin.poll_booth_assignments.flash.error_destroy")
end
redirect_to admin_poll_path(@booth_assignment.poll_id, anchor: 'tab-booths'), notice: notice
end
def show
@poll = ::Poll.find(params[:poll_id])
@booth_assignment = @poll.booth_assignments.includes(:recounts, :final_recounts, :voters, officer_assignments: [officer: [:user]]).find(params[:id])
@voters_by_date = @booth_assignment.voters.group_by {|v| v.created_at.to_date}
redirect_to admin_poll_booth_assignments_path(@booth_assignment.poll_id), notice: notice
end
private
@@ -38,4 +51,16 @@ class Admin::Poll::BoothAssignmentsController < Admin::BaseController
params.permit(:booth, :poll)
end
def load_poll
@poll = ::Poll.find(params[:poll_id])
end
def search_params
params.permit(:poll_id, :search)
end
def load_search
@search = search_params[:search]
end
end

View File

@@ -1,11 +1,16 @@
class Admin::Poll::OfficerAssignmentsController < Admin::BaseController
before_action :redirect_if_blank_required_params, only: [:index]
before_action :load_poll
before_action :redirect_if_blank_required_params, only: [:by_officer]
before_action :load_booth_assignment, only: [:create]
def index
@poll = ::Poll.includes(:booths).find(officer_assignment_params[:poll])
@officer = ::Poll::Officer.includes(:user).find(officer_assignment_params[:officer])
@officers = @poll.officer_assignments.includes(officer: :user).select(:officer_id).distinct.map(&:officer)
end
def by_officer
@poll = ::Poll.includes(:booths).find(params[:poll_id])
@officer = ::Poll::Officer.includes(:user).find(officer_assignment_params[:officer_id])
@officer_assignments = ::Poll::OfficerAssignment.
joins(:booth_assignment).
includes(:recount, :final_recounts, booth_assignment: :booth).
@@ -13,6 +18,15 @@ class Admin::Poll::OfficerAssignmentsController < Admin::BaseController
order(:date)
end
def search_officers
load_search
@officers = User.joins(:poll_officer).search(@search).order(username: :asc)
respond_to do |format|
format.js
end
end
def create
@officer_assignment = ::Poll::OfficerAssignment.new(booth_assignment: @booth_assignment,
officer_id: create_params[:officer_id],
@@ -24,7 +38,7 @@ class Admin::Poll::OfficerAssignmentsController < Admin::BaseController
else
notice = t("admin.poll_officer_assignments.flash.error_create")
end
redirect_to admin_officer_assignments_path(officer: create_params[:officer_id], poll: create_params[:poll_id]), notice: notice
redirect_to by_officer_admin_poll_officer_assignments_path(poll_id: create_params[:poll_id], officer_id: create_params[:officer_id]), notice: notice
end
def destroy
@@ -35,13 +49,13 @@ class Admin::Poll::OfficerAssignmentsController < Admin::BaseController
else
notice = t("admin.poll_officer_assignments.flash.error_destroy")
end
redirect_to admin_officer_assignments_path(officer: @officer_assignment.officer_id, poll: @officer_assignment.poll_id), notice: notice
redirect_to by_officer_admin_poll_officer_assignments_path(poll_id: @officer_assignment.poll_id, officer_id: @officer_assignment.officer_id), notice: notice
end
private
def officer_assignment_params
params.permit(:officer, :poll)
params.permit(:officer_id)
end
def create_params
@@ -52,14 +66,22 @@ class Admin::Poll::OfficerAssignmentsController < Admin::BaseController
@booth_assignment = ::Poll::BoothAssignment.includes(:poll).find_by(poll_id: create_params[:poll_id], booth_id: create_params[:booth_id])
end
def load_poll
@poll = ::Poll.find(params[:poll_id])
end
def redirect_if_blank_required_params
if officer_assignment_params[:officer].blank?
if officer_assignment_params[:poll].blank?
redirect_to admin_polls_path
else
redirect_to admin_poll_path(officer_assignment_params[:poll])
end
if officer_assignment_params[:officer_id].blank?
redirect_to admin_poll_path(@poll)
end
end
def search_params
params.permit(:poll_id, :search)
end
def load_search
@search = search_params[:search]
end
end

View File

@@ -8,12 +8,8 @@ class Admin::Poll::PollsController < Admin::BaseController
end
def show
@poll = Poll.includes(:questions,
booth_assignments: [:booth,
:final_recounts,
:recounts],
officers: [:user]).
order('poll_questions.title', 'poll_booths.name', 'users.username').
@poll = Poll.includes(:questions).
order('poll_questions.title').
find(params[:id])
end
@@ -48,7 +44,7 @@ class Admin::Poll::PollsController < Admin::BaseController
else
notice = t("admin.polls.flash.error_on_question_added")
end
redirect_to admin_poll_path(@poll, anchor: 'tab-questions'), notice: notice
redirect_to admin_poll_path(@poll), notice: notice
end
def remove_question
@@ -60,14 +56,7 @@ class Admin::Poll::PollsController < Admin::BaseController
else
notice = t("admin.polls.flash.error_on_question_removed")
end
redirect_to admin_poll_path(@poll, anchor: 'tab-questions'), notice: notice
end
def search_booths
@booths = ::Poll::Booth.search(@search)
respond_to do |format|
format.js
end
redirect_to admin_poll_path(@poll), notice: notice
end
def search_questions
@@ -77,14 +66,6 @@ class Admin::Poll::PollsController < Admin::BaseController
end
end
def search_officers
@officers = User.joins(:poll_officer).search(@search).order(username: :asc)
respond_to do |format|
format.js
end
end
private
def load_geozones
@geozones = Geozone.all.order(:name)

View File

@@ -0,0 +1,13 @@
class Admin::Poll::RecountsController < Admin::BaseController
before_action :load_poll
def index
@booth_assignments = @poll.booth_assignments.includes(:recounts, :final_recounts)
end
private
def load_poll
@poll = ::Poll.find(params[:poll_id])
end
end

View File

@@ -0,0 +1,13 @@
class Admin::Poll::ResultsController < Admin::BaseController
before_action :load_poll
def index
@partial_results = @poll.partial_results
end
private
def load_poll
@poll = ::Poll.includes(:questions).find(params[:poll_id])
end
end

View File

@@ -25,7 +25,7 @@ module AdminHelper
end
def menu_polls?
["polls", "questions", "officers", "booths", "officer_assignments", "booth_assignments"].include? controller_name
["polls", "questions", "officers", "booths", "officer_assignments", "booth_assignments", "recounts", "results"].include? controller_name
end
def menu_profiles?

View File

@@ -61,7 +61,7 @@
<strong><%= t("admin.menu.title_polls") %></strong>
</a>
<ul id="polls_menu" <%= "class=is-active" if menu_polls? %>>
<li <%= 'class=active' if ["polls", "officer_assignments", "booth_assignments"].include? controller_name %>>
<li <%= 'class=active' if ["polls", "officer_assignments", "booth_assignments", "recounts", "results"].include? controller_name %>>
<%= link_to t('admin.menu.polls'), admin_polls_path %>
</li>

View File

@@ -1,6 +1,6 @@
<div class="row">
<div class="small-12 medium-6 column">
<%= form_tag(search_booths_admin_poll_path(@poll), method: :get, remote: true) do |f| %>
<%= form_tag(search_booths_admin_poll_booth_assignments_path(@poll), method: :get, remote: true) do |f| %>
<div class="input-group">
<%= text_field_tag :search,
@search,

View File

@@ -1,18 +1,18 @@
<% if @booths.blank? %>
<div class="callout alert margin-bottom">
<%= t('admin.polls.show.no_search_results') %>
<%= t('admin.shared.no_search_results') %>
</div>
<% else %>
<h3><%= t('admin.polls.show.search_results') %></h3>
<h3><%= t('admin.shared.search_results') %></h3>
<% end %>
<% if @booths.any? %>
<table>
<thead>
<tr>
<th><%= t("admin.polls.show.table_name") %></th>
<th><%= t("admin.polls.show.table_location") %></th>
<th class="text-center"><%= t("admin.polls.show.table_assignment") %></th>
<th><%= t("admin.poll_booth_assignments.index.table_name") %></th>
<th><%= t("admin.poll_booth_assignments.index.table_location") %></th>
<th class="text-center"><%= t("admin.poll_booth_assignments.index.table_assignment") %></th>
</tr>
</thead>
<tbody>
@@ -26,13 +26,12 @@
</td>
<td class="text-center">
<% if @poll.booth_ids.include?(booth.id) %>
<%= link_to t("admin.polls.show.remove_booth"),
admin_booth_assignment_path(poll: @poll, booth: booth),
<%= link_to t("admin.poll_booth_assignments.index.remove_booth"),
method: :delete,
class: "button hollow alert" %>
<% else %>
<%= link_to t("admin.polls.show.add_booth"),
admin_booth_assignments_path(poll: @poll, booth: booth),
<%= link_to t("admin.poll_booth_assignments.index.add_booth"),
admin_poll_booth_assignments_path(poll: @poll, booth: booth),
method: :post,
class: "button hollow" %>
<% end %>

View File

@@ -0,0 +1,41 @@
<%= render "/admin/poll/polls/poll_header" %>
<div id="poll-resources">
<%= render "/admin/poll/polls/subnav" %>
<%= render "search_booths" %>
<h3><%= t("admin.poll_booth_assignments.index.booths_title") %></h3>
<% if @poll.booth_assignments.empty? %>
<div class="callout primary margin-top">
<%= t("admin.poll_booth_assignments.index.no_booths") %>
</div>
<% else %>
<table id="assigned_booths_list" class="fixed margin">
<thead>
<th><%= t("admin.poll_booth_assignments.index.table_name") %></th>
<th><%= t("admin.poll_booth_assignments.index.table_location") %></th>
<th class="text-right"><%= t("admin.poll_booth_assignments.index.table_assignment") %></th>
</thead>
<tbody>
<% @poll.booth_assignments.each do |booth_assignment| %>
<tr id="<%= dom_id(booth_assignment) %>" class="booth">
<td>
<strong>
<%= link_to booth_assignment.booth.name, admin_poll_booth_assignment_path(@poll, booth_assignment) %>
</strong>
</td>
<td>
<%= booth_assignment.booth.location %>
</td>
<td class="text-right">
<%= link_to t("admin.poll_booth_assignments.index.remove_booth"),
admin_poll_booth_assignment_path(@poll, booth_assignment),
method: :delete,
class: "button hollow alert" %>
</td>
</tr>
<% end %>
</tbody>
</table>
<% end %>
</div>

View File

@@ -1,4 +1,4 @@
<%= link_to admin_poll_path(@poll, anchor: 'tab-booths') do %>
<%= link_to admin_poll_booth_assignments_path(@poll) do %>
<span class="icon-angle-left"></span>
<%= @poll.name %>
<% end %>
@@ -34,7 +34,7 @@
<tbody>
<% @booth_assignment.officers.uniq.each do |officer| %>
<tr id="officer_<%= officer.id %>" class="officer">
<td><%= link_to officer.name, admin_officer_assignments_path(officer: officer, poll: @poll) %></td>
<td><%= link_to officer.name, by_officer_admin_poll_officer_assignments_path(@poll, officer_id: officer.id) %></td>
<td><%= officer.email %></td>
</tr>
<% end %>

View File

@@ -1,6 +1,6 @@
<div class="row">
<div class="small-12 medium-6 column">
<%= form_tag(search_officers_admin_poll_path(@poll), method: :get, remote: true) do |f| %>
<%= form_tag(search_officers_admin_poll_officer_assignments_path(@poll), method: :get, remote: true) do |f| %>
<div class="input-group">
<%= text_field_tag :search,
@search,

View File

@@ -1,17 +1,17 @@
<% if @officers.blank? %>
<div class="callout alert margin-bottom">
<%= t('admin.polls.show.no_search_results') %>
<%= t('admin.shared.no_search_results') %>
</div>
<% else %>
<h3><%= t('admin.polls.show.search_results') %></h3>
<h3><%= t('admin.shared.search_results') %></h3>
<% end %>
<% if @officers.any? %>
<table>
<thead>
<tr>
<th><%= t("admin.polls.show.table_name") %></th>
<th><%= t("admin.polls.show.table_email") %></th>
<th><%= t("admin.poll_officer_assignments.index.table_name") %></th>
<th><%= t("admin.poll_officer_assignments.index.table_email") %></th>
<th class="text-center"><%= t("admin.polls.show.table_assignment") %></th>
</tr>
</thead>
@@ -26,12 +26,12 @@
</td>
<td class="text-center">
<% if @poll.officer_ids.include?(user.poll_officer.id) %>
<%= link_to t("admin.polls.show.edit_officer_assignments"),
admin_officer_assignments_path(poll: @poll, officer: user.poll_officer),
<%= link_to t("admin.poll_officer_assignments.index.edit_officer_assignments"),
by_officer_admin_poll_officer_assignments_path(@poll, officer_id: user.poll_officer.id),
class: "button hollow alert" %>
<% else %>
<%= link_to t("admin.polls.show.add_officer_assignments"),
admin_officer_assignments_path(poll: @poll, officer: user.poll_officer),
<%= link_to t("admin.poll_officer_assignments.index.add_officer_assignments"),
by_officer_admin_poll_officer_assignments_path(@poll, officer_id: user.poll_officer.id),
class: "button hollow" %>
<% end %>
</td>

View File

@@ -0,0 +1,127 @@
<%= link_to admin_poll_officer_assignments_path(@poll) do %>
<span class="icon-angle-left"></span>
<%= @poll.name %>
<% end %>
<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") %>
</div>
<% else %>
<h3><%= t("admin.poll_officer_assignments.by_officer.assignments") %></h3>
<table class="fixed">
<thead>
<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>
<% @officer_assignments.each do |officer_assignment| %>
<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>
</table>
<% end %>
<% voting_days_officer_assignments = @officer_assignments.select{|oa| oa.final == false} %>
<% if voting_days_officer_assignments.any? %>
<h3><%= t("admin.poll_officer_assignments.by_officer.recounts") %></h3>
<table id="recount_list" class="fixed">
<thead>
<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.recount") %></th>
</tr>
</thead>
<tbody>
<% voting_days_officer_assignments.each do |officer_assignment| %>
<tr id="recount_<%= officer_assignment.date.to_date.strftime('%Y%m%d') %>">
<td><%= l(officer_assignment.date.to_date) %></td>
<td><%= booth_name_with_location(officer_assignment.booth_assignment.booth) %></td>
<td class="text-right">
<% if officer_assignment.recount.present? %>
<%= officer_assignment.recount.count %>
<% else %>
<span>-</span>
<% end %>
</td>
</tr>
<% end %>
</tbody>
</table>
<% end %>
<% final_officer_assignments = @officer_assignments.select{|oa| oa.final == true} %>
<% if final_officer_assignments.any? %>
<h3><%= t("admin.poll_officer_assignments.by_officer.final_recounts") %></h3>
<table id="final_recount_list" class="fixed">
<thead>
<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.final_recount") %></th>
</tr>
</thead>
<tbody>
<% final_officer_assignments.each do |officer_assignment| %>
<tr id="final_recount_<%= officer_assignment.date.to_date.strftime('%Y%m%d') %>">
<td><%= l(officer_assignment.date.to_date) %></td>
<td><%= booth_name_with_location(officer_assignment.booth_assignment.booth) %></td>
<td class="text-right">
<% if officer_assignment.final_recounts.any? %>
<%= officer_assignment.final_recounts.to_a.sum(&:count) %>
<% else %>
<span>-</span>
<% end %>
</td>
</tr>
<% end %>
</tbody>
</table>
<% end %>

View File

@@ -1,127 +1,41 @@
<%= link_to admin_poll_path(@poll, anchor: 'tab-officers') do %>
<span class="icon-angle-left"></span>
<%= @poll.name %>
<% end %>
<%= render "/admin/poll/polls/poll_header" %>
<div id="poll-resources">
<%= render "/admin/poll/polls/subnav" %>
<h2><%= @officer.name %> - <%= @officer.email %></h2>
<%= render "search_officers" %>
<%= form_tag(admin_officer_assignments_path, {id: "officer_assignment_form"}) do %>
<fieldset class="fieldset">
<legend><%= t("admin.poll_officer_assignments.index.new_assignment") %></legend>
<div class="small-12 medium-4 column">
<label><%= t("admin.poll_officer_assignments.index.date") %></label>
<%= select_tag :date,
poll_dates_select_options(@poll) + poll_final_recount_option(@poll),
{ prompt: t("admin.poll_officer_assignments.index.select_date"),
label: false } %>
<h3><%= t("admin.poll_officer_assignments.index.officers_title") %></h3>
<% if @officers.empty? %>
<div class="callout primary margin-top">
<%= t("admin.poll_officer_assignments.index.no_officers") %>
</div>
<div class="small-12 medium-4 column">
<label><%= t("admin.poll_officer_assignments.index.booth") %></label>
<%= select_tag :booth_id,
poll_booths_select_options(@poll),
{ prompt: t("admin.poll_officer_assignments.index.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.index.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.index.no_assignments") %>
</div>
<% else %>
<h3><%= t("admin.poll_officer_assignments.index.assignments") %></h3>
<table class="fixed">
<thead>
<tr>
<th><%= t("admin.poll_officer_assignments.index.date") %></th>
<th><%= t("admin.poll_officer_assignments.index.booth") %></th>
<th class="text-right"><%= t("admin.poll_officer_assignments.index.assignment") %></th>
</tr>
</thead>
<tbody>
<% @officer_assignments.each do |officer_assignment| %>
<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.index.remove_assignment"),
admin_officer_assignment_path(officer_assignment),
method: :delete,
class: "button hollow alert" %>
</td>
</tr>
<% end %>
</tbody>
</table>
<% end %>
<% voting_days_officer_assignments = @officer_assignments.select{|oa| oa.final == false} %>
<% if voting_days_officer_assignments.any? %>
<h3><%= t("admin.poll_officer_assignments.index.recounts") %></h3>
<table id="recount_list" class="fixed">
<thead>
<tr>
<th><%= t("admin.poll_officer_assignments.index.date") %></th>
<th><%= t("admin.poll_officer_assignments.index.booth") %></th>
<th class="text-right"><%= t("admin.poll_officer_assignments.index.recount") %></th>
</tr>
</thead>
<tbody>
<% voting_days_officer_assignments.each do |officer_assignment| %>
<tr id="recount_<%= officer_assignment.date.to_date.strftime('%Y%m%d') %>">
<td><%= l(officer_assignment.date.to_date) %></td>
<td><%= booth_name_with_location(officer_assignment.booth_assignment.booth) %></td>
<td class="text-right">
<% if officer_assignment.recount.present? %>
<%= officer_assignment.recount.count %>
<% else %>
<span>-</span>
<% end %>
</td>
</tr>
<% end %>
</tbody>
</table>
<% end %>
<% final_officer_assignments = @officer_assignments.select{|oa| oa.final == true} %>
<% if final_officer_assignments.any? %>
<h3><%= t("admin.poll_officer_assignments.index.final_recounts") %></h3>
<table id="final_recount_list" class="fixed">
<thead>
<tr>
<th><%= t("admin.poll_officer_assignments.index.date") %></th>
<th><%= t("admin.poll_officer_assignments.index.booth") %></th>
<th class="text-right"><%= t("admin.poll_officer_assignments.index.final_recount") %></th>
</tr>
</thead>
<tbody>
<% final_officer_assignments.each do |officer_assignment| %>
<tr id="final_recount_<%= officer_assignment.date.to_date.strftime('%Y%m%d') %>">
<td><%= l(officer_assignment.date.to_date) %></td>
<td><%= booth_name_with_location(officer_assignment.booth_assignment.booth) %></td>
<% else %>
<table class="fixed margin">
<thead>
<th><%= t("admin.poll_officer_assignments.index.table_name") %></th>
<th><%= t("admin.poll_officer_assignments.index.table_email") %></th>
<th class="text-right"><%= t("admin.actions.actions") %></th>
</thead>
<tbody>
<% @officers.each do |officer| %>
<tr id="officer_<%= officer.id %>" class="officer">
<td>
<strong>
<%= link_to officer.name, by_officer_admin_poll_officer_assignments_path(@poll, officer_id: officer.id) %>
</strong>
</td>
<td>
<%= officer.email %>
</td>
<td class="text-right">
<% if officer_assignment.final_recounts.any? %>
<%= officer_assignment.final_recounts.to_a.sum(&:count) %>
<% else %>
<span>-</span>
<% end %>
<%= link_to t("admin.poll_officer_assignments.index.edit_officer_assignments"),
by_officer_admin_poll_officer_assignments_path(@poll, officer_id: officer.id),
class: "button hollow" %>
</td>
</tr>
<% end %>
</tbody>
</table>
<% end %>
<% end %>
</tbody>
</table>
<% end %>
</div>

View File

@@ -1,35 +0,0 @@
<h3><%= t("admin.polls.show.booths_title") %></h3>
<% if @poll.booth_assignments.empty? %>
<div class="callout primary margin-top">
<%= t("admin.polls.show.no_booths") %>
</div>
<% else %>
<table id="assigned_booths_list" class="fixed margin">
<thead>
<th><%= t("admin.polls.show.table_name") %></th>
<th><%= t("admin.polls.show.table_location") %></th>
<th class="text-right"><%= t("admin.polls.show.table_assignment") %></th>
</thead>
<tbody>
<% @poll.booth_assignments.each do |booth_assignment| %>
<tr id="<%= dom_id(booth_assignment) %>" class="booth">
<td>
<strong>
<%= link_to booth_assignment.booth.name, admin_poll_booth_assignment_path(@poll, booth_assignment) %>
</strong>
</td>
<td>
<%= booth_assignment.booth.location %>
</td>
<td class="text-right">
<%= link_to t("admin.polls.show.remove_booth"),
admin_booth_assignment_path(booth_assignment),
method: :delete,
class: "button hollow alert" %>
</td>
</tr>
<% end %>
</tbody>
</table>
<% end %>

View File

@@ -1,30 +0,0 @@
<ul class="tabs" data-tabs id="assigned-resources-tabs">
<li class="tabs-title is-active">
<%= link_to "#tab-questions" do %>
<%= t("admin.polls.show.questions_tab") %>
<span class="js-comments-count">(<%= @poll.questions.count %>)</span>
<% end %>
</li>
<li class="tabs-title">
<%= link_to "#tab-booths" do %>
<%= t("admin.polls.show.booths_tab") %>
(<%= @poll.booths.count %>)
<% end %>
</li>
<li class="tabs-title">
<%= link_to "#tab-officers" do %>
<%= t("admin.polls.show.officers_tab") %>
(<%= @poll.officers.uniq.count %>)
<% end %>
</li>
<li class="tabs-title">
<%= link_to "#tab-recounts" do %>
<%= t("admin.polls.show.recounts_tab") %>
<% end %>
</li>
<li class="tabs-title">
<%= link_to "#tab-results" do %>
<%= t("admin.polls.show.results_tab") %>
<% end %>
</li>
</ul>

View File

@@ -1,34 +0,0 @@
<h3><%= t("admin.polls.show.officers_title") %></h3>
<% if @poll.officers.empty? %>
<div class="callout primary margin-top">
<%= t("admin.polls.show.no_officers") %>
</div>
<% else %>
<table class="fixed margin">
<thead>
<th><%= t("admin.polls.show.table_name") %></th>
<th><%= t("admin.polls.show.table_email") %></th>
<th class="text-right"><%= t("admin.actions.actions") %></th>
</thead>
<tbody>
<% @poll.officers.uniq.each do |officer| %>
<tr id="officer_<%= officer.id %>" class="officer">
<td>
<strong>
<%= link_to officer.name, admin_officer_assignments_path(officer: officer, poll: @poll) %>
</strong>
</td>
<td>
<%= officer.email %>
</td>
<td class="text-right">
<%= link_to t("admin.polls.show.edit_officer_assignments"),
admin_officer_assignments_path(officer: officer, poll: @poll),
class: "button hollow" %>
</td>
</tr>
<% end %>
</tbody>
</table>
<% end %>

View File

@@ -0,0 +1,17 @@
<%= link_to t("admin.actions.edit"),
edit_admin_poll_path(@poll),
class: "button hollow float-right" %>
<h2 class="inline-block">
<%= @poll.name %>
</h2>
<br>
<span>
(<%= l @poll.starts_at.to_date %> - <%= l @poll.ends_at.to_date %>)
</span>
<% if @poll.geozone_restricted %>
<span class="bullet">&nbsp;&bull;&nbsp;</span>
<span>
<%= @poll.geozones.pluck(:name).to_sentence %>
<span>
<% end %>

View File

@@ -1,40 +0,0 @@
<h3><%= t("admin.polls.show.recounting_title") %></h3>
<% if @poll.booth_assignments.empty? %>
<div class="callout primary margin-top">
<%= t("admin.polls.show.no_recounts") %>
</div>
<% else %>
<table class="fixed margin">
<thead>
<th><%= t("admin.polls.show.table_booth_name") %></th>
<th class="text-center"><%= t("admin.polls.show.table_recounts") %></th>
<th class="text-center"><%= t("admin.polls.show.table_final_recount") %></th>
</thead>
<tbody>
<% @poll.booth_assignments.each do |booth_assignment| %>
<tr id="<%= dom_id(booth_assignment) %>_recounts" class="booth_recounts">
<td>
<strong>
<%= link_to booth_assignment.booth.name, admin_poll_booth_assignment_path(@poll, booth_assignment, anchor: 'tab-recounts') %>
</strong>
</td>
<td class="text-center">
<% if booth_assignment.recounts.any? %>
<%= booth_assignment.recounts.to_a.sum(&:count) %>
<% else %>
<span>-</span>
<% end %>
</td>
<td class="text-center">
<% if booth_assignment.final_recounts.any? %>
<strong><%= booth_assignment.final_recounts.to_a.sum(&:count) %></strong>
<% else %>
<span>-</span>
<% end %>
</td>
</tr>
<% end %>
</tbody>
</table>
<% end %>

View File

@@ -1,45 +0,0 @@
<h3><%= t("admin.polls.show.results_title") %></h3>
<% if @poll.partial_results.empty? %>
<div class="callout primary margin-top">
<%= t("admin.polls.show.no_results") %>
</div>
<% else %>
<table class="margin">
<thead>
<th><%= t("admin.polls.show.table_whites") %></th>
<th><%= t("admin.polls.show.table_nulls") %></th>
</thead>
<tbody>
<tr>
<td id="white_results"><%= @poll.white_results.sum(:amount) %></td>
<td id="null_results"><%= @poll.null_results.sum(:amount) %></td>
</tr>
</tbody>
</table>
<% by_question = @poll.partial_results.group_by(&:question_id) %>
<% @poll.questions.each do |question| %>
<h3><%= question.title %></h3>
<table class="margin">
<thead>
<tr>
<th><%= t("admin.polls.show.table_answer") %></th>
<th class="text-center"><%= t("admin.polls.show.table_votes") %></th>
</tr>
</thead>
<tbody>
<% question.valid_answers.each_with_index do |answer, i| %>
<% by_answer = by_question[question.id].present? ? by_question[question.id].group_by(&:answer) : {} %>
<tr id="question_<%= question.id %>_<%= i %>_result">
<td><%= answer %></td>
<td class="text-center"><%= by_answer[answer].present? ? by_answer[answer].sum(&:amount) : 0 %></td>
</tr>
<% end %>
</tbody>
</table>
<% end %>
<% end %>

View File

@@ -1,9 +1,9 @@
<% if @questions.blank? %>
<div class="callout alert margin-bottom">
<%= t('admin.polls.show.no_search_results') %>
<%= t('admin.shared.no_search_results') %>
</div>
<% else %>
<h3><%= t('admin.polls.show.search_results') %></h3>
<h3><%= t('admin.shared.search_results') %></h3>
<% end %>
<% if @questions.any? %>

View File

@@ -0,0 +1,63 @@
<ul class="menu simple clear" id="assigned-resources-tabs">
<% if controller_name == "polls" %>
<li class="active">
<%= t("admin.polls.show.questions_tab") %>
(<%= @poll.questions.count %>)
</li>
<% else %>
<li>
<%= link_to admin_poll_path(@poll) do %>
<%= t("admin.polls.show.questions_tab") %>
(<%= @poll.questions.count %>)
<% end %>
</li>
<% end %>
<% if controller_name == "booth_assignments" %>
<li class="active">
<%= t("admin.polls.show.booths_tab") %>
(<%= @poll.booth_assignments.select(:booth_id).distinct.count %>)
</li>
<% else %>
<li>
<%= link_to admin_poll_booth_assignments_path(@poll) do %>
<%= t("admin.polls.show.booths_tab") %>
(<%= @poll.booth_assignments.select(:booth_id).distinct.count %>)
<% end %>
</li>
<% end %>
<% if controller_name == "officer_assignments" %>
<li class="active">
<%= t("admin.polls.show.officers_tab") %>
(<%= @poll.officer_assignments.select(:officer_id).distinct.count %>)
</li>
<% else %>
<li>
<%= link_to admin_poll_officer_assignments_path(@poll) do %>
<%= t("admin.polls.show.officers_tab") %>
(<%= @poll.officer_assignments.select(:officer_id).distinct.count %>)
<% end %>
</li>
<% end %>
<% if controller_name == "recounts" %>
<li class="active">
<%= t("admin.polls.show.recounts_tab") %>
</li>
<% else %>
<li>
<%= link_to t("admin.polls.show.recounts_tab"), admin_poll_recounts_path(@poll) %>
</li>
<% end %>
<% if controller_name == "results" %>
<li class="active">
<%= t("admin.polls.show.results_tab") %>
</li>
<% else %>
<li>
<%= link_to t("admin.polls.show.results_tab"), admin_poll_results_path(@poll) %>
</li>
<% end %>
</ul%>

View File

@@ -1,44 +1,8 @@
<%= link_to t("admin.actions.edit"),
edit_admin_poll_path(@poll),
class: "button hollow float-right" %>
<%= render "poll_header" %>
<h2 class="inline-block">
<%= @poll.name %>
</h2>
<br>
<span>
(<%= l @poll.starts_at.to_date %> - <%= l @poll.ends_at.to_date %>)
</span>
<% if @poll.geozone_restricted %>
<span class="bullet">&nbsp;&bull;&nbsp;</span>
<span>
<%= @poll.geozones.pluck(:name).to_sentence %>
<span>
<% end %>
<div id="poll-resources">
<%= render "subnav" %>
<div id="poll-resources" class="tabs-content" data-tabs-content="assigned-resources-tabs">
<%= render "filter_subnav" %>
<div class="tabs-panel is-active" id="tab-questions">
<%= render "search_questions" %>
<%= render "questions" %>
</div>
<div class="tabs-panel" id="tab-booths">
<%= render "search_booths" %>
<%= render "booths" %>
</div>
<div class="tabs-panel" id="tab-officers">
<%= render "search_officers" %>
<%= render 'officers' %>
</div>
<div class="tabs-panel" id="tab-recounts">
<%= render 'recounting' %>
</div>
<div class="tabs-panel" id="tab-results">
<%= render 'results' %>
</div>
<%= render "search_questions" %>
<%= render "questions" %>
</div>

View File

@@ -0,0 +1,45 @@
<%= render "/admin/poll/polls/poll_header" %>
<div id="poll-resources">
<%= render "/admin/poll/polls/subnav" %>
<h3><%= t("admin.recounts.index.title") %></h3>
<% if @booth_assignments.empty? %>
<div class="callout primary margin-top">
<%= t("admin.recounts.index.no_recounts") %>
</div>
<% else %>
<table class="fixed margin">
<thead>
<th><%= t("admin.recounts.index.table_booth_name") %></th>
<th class="text-center"><%= t("admin.recounts.index.table_recounts") %></th>
<th class="text-center"><%= t("admin.recounts.index.table_final_recount") %></th>
</thead>
<tbody>
<% @booth_assignments.each do |booth_assignment| %>
<tr id="<%= dom_id(booth_assignment) %>_recounts" class="booth_recounts">
<td>
<strong>
<%= link_to booth_assignment.booth.name, admin_poll_booth_assignment_path(@poll, booth_assignment, anchor: 'tab-recounts') %>
</strong>
</td>
<td class="text-center">
<% if booth_assignment.recounts.any? %>
<%= booth_assignment.recounts.to_a.sum(&:count) %>
<% else %>
<span>-</span>
<% end %>
</td>
<td class="text-center">
<% if booth_assignment.final_recounts.any? %>
<strong><%= booth_assignment.final_recounts.to_a.sum(&:count) %></strong>
<% else %>
<span>-</span>
<% end %>
</td>
</tr>
<% end %>
</tbody>
</table>
<% end %>
</div>

View File

@@ -0,0 +1,50 @@
<%= render "/admin/poll/polls/poll_header" %>
<div id="poll-resources">
<%= render "/admin/poll/polls/subnav" %>
<h3><%= t("admin.results.index.title") %></h3>
<% if @partial_results.empty? %>
<div class="callout primary margin-top">
<%= t("admin.results.index.no_results") %>
</div>
<% else %>
<table class="margin">
<thead>
<th><%= t("admin.results.index.table_whites") %></th>
<th><%= t("admin.results.index.table_nulls") %></th>
</thead>
<tbody>
<tr>
<td id="white_results"><%= @poll.white_results.sum(:amount) %></td>
<td id="null_results"><%= @poll.null_results.sum(:amount) %></td>
</tr>
</tbody>
</table>
<% by_question = @partial_results.group_by(&:question_id) %>
<% @poll.questions.each do |question| %>
<h3><%= question.title %></h3>
<table class="margin">
<thead>
<tr>
<th><%= t("admin.results.index.table_answer") %></th>
<th class="text-center"><%= t("admin.results.index.table_votes") %></th>
</tr>
</thead>
<tbody>
<% question.valid_answers.each_with_index do |answer, i| %>
<% by_answer = by_question[question.id].present? ? by_question[question.id].group_by(&:answer) : {} %>
<tr id="question_<%= question.id %>_<%= i %>_result">
<td><%= answer %></td>
<td class="text-center"><%= by_answer[answer].present? ? by_answer[answer].sum(&:amount) : 0 %></td>
</tr>
<% end %>
</tbody>
</table>
<% end %>
<% end %>
</div>

View File

@@ -271,6 +271,13 @@ en:
error_destroy: "An error ocurred when removing officer assignment"
error_create: "An error ocurred when adding officer assignment"
index:
officers_title: "List of officers"
no_officers: "There are no officers assigned to this poll."
table_name: "Name"
table_email: "Email"
add_officer_assignments: "Add shifts as officer"
edit_officer_assignments: "Edit officing shifts"
by_officer:
new_assignment: "New shift"
date: "Date"
booth: "Booth"
@@ -286,6 +293,11 @@ en:
final_recounts: "Final recounts"
final_recount: "Final recount (by officer)"
poll_booth_assignments:
flash:
destroy: "Booth not assigned anymore"
create: "Booth assigned"
error_destroy: "An error ocurred when removing booth assignment"
error_create: "An error ocurred when assigning booth to the poll"
show:
location: "Location"
officers: "Officers"
@@ -298,6 +310,14 @@ en:
count_by_officer: "Daily recount (by officer)"
count_final: "Final recount (by officer)"
count_by_system: "Votes (automatic)"
index:
booths_title: "List of booths"
no_booths: "There are no booths assigned to this poll."
table_name: "Name"
table_location: "Location"
table_assignment: "Assignment"
remove_booth: "Remove booth from poll"
add_booth: "Assign booth"
polls:
index:
title: "List of polls"
@@ -317,36 +337,13 @@ en:
officers_tab: Officers
recounts_tab: Recounting
results_tab: Results
no_booths: "There are no booths assigned to this poll."
no_questions: "There are no questions assigned to this poll."
no_officers: "There are no officers assigned to this poll."
no_recounts: "There is nothing to be recounted"
no_results: "There are no results"
remove_booth: "Remove booth from poll"
booths_title: "List of booths"
officers_title: "List of officers"
questions_title: "List of questions"
recounting_title: "Recounts"
results_title: "Results"
remove_question: "Remove question from poll"
add_booth: "Assign booth"
add_question: "Include question"
add_officer_assignments: "Add shifts as officer"
edit_officer_assignments: "Edit officing shifts"
search_results: "Search results"
no_search_results: "No results found."
table_title: "Title"
table_assignment: "Assignment"
table_name: "Name"
table_location: "Location"
table_email: "Email"
table_booth_name: "Booth"
table_final_recount: "Final recount (by officer)"
table_recounts: "Accumulated daily recounts (by officer)"
table_whites: "Blank ballots"
table_nulls: "Invalid ballots"
table_answer: Answer
table_votes: Votes
flash:
question_added: "Question added to this poll"
error_on_question_added: "Question could not be assigned to this poll"
@@ -377,6 +374,21 @@ en:
valid_answers: Valid answers
description: Description
preview: View on website
recounts:
index:
title: "Recounts"
no_recounts: "There is nothing to be recounted"
table_booth_name: "Booth"
table_recounts: "Accumulated daily recounts (by officer)"
table_final_recount: "Final recount (by officer)"
results:
index:
title: "Results"
no_results: "There are no results"
table_whites: "Blank ballots"
table_nulls: "Invalid ballots"
table_answer: Answer
table_votes: Votes
booths:
index:
title: "List of booths"
@@ -394,12 +406,6 @@ en:
submit_button: "Update booth"
show:
location: "Location"
booth_assignments:
flash:
destroy: "Booth not assigned anymore"
create: "Booth assigned"
error_destroy: "An error ocurred when removing booth assignment"
error_create: "An error ocurred when assigning booth to the poll"
officials:
edit:
destroy: Remove 'Official' status
@@ -480,6 +486,8 @@ en:
user_search:
button: Search
placeholder: Search user by name or email'
search_results: "Search results"
no_search_results: "No results found."
spending_proposals:
index:
geozone_filter_all: All zones

View File

@@ -271,6 +271,13 @@ es:
error_destroy: "Se ha producido un error al eliminar el turno"
error_create: "Se ha producido un error al intentar crear el turno"
index:
officers_title: "Listado de presidentes de mesa asignados"
no_officers: "No hay presidentes de mesa asignados a esta votación."
table_name: "Nombre"
table_email: "Email"
add_officer_assignments: "Añadir turnos como presidente de mesa"
edit_officer_assignments: "Editar turnos"
by_officer:
new_assignment: "Nuevo turno"
date: "Fecha"
booth: "Urna"
@@ -286,6 +293,11 @@ es:
final_recounts: "Recuentos finales"
final_recount: "Recuento final (presidente de mesa)"
poll_booth_assignments:
flash:
destroy: "Urna desasignada"
create: "Urna asignada"
error_destroy: "Se ha producido un error al desasignar la urna"
error_create: "Se ha producido un error al intentar asignar la urna"
show:
location: "Ubicación"
officers: "Presidentes de mesa"
@@ -298,6 +310,14 @@ es:
count_by_officer: "Recuento diario (presidente de mesa)"
count_final: "Recuento final (presidente de mesa)"
count_by_system: "Votos (automático)"
index:
booths_title: "Listado de urnas asignadas"
no_booths: "No hay urnas asignadas a esta votación."
table_name: "Nombre"
table_location: "Ubicación"
table_assignment: "Asignación"
remove_booth: "Desasignar urna"
add_booth: "Asignar urna"
polls:
index:
title: "Listado de votaciones"
@@ -317,36 +337,13 @@ es:
officers_tab: Presidentes de mesa
recounts_tab: Recuentos
results_tab: Resultados
no_booths: "No hay urnas asignadas a esta votación."
no_questions: "No hay preguntas asignadas a esta votación."
no_officers: "No hay presidentes de mesa asignados a esta votación."
no_recounts: "No hay nada de lo que hacer recuento"
no_results: "No hay resultados"
remove_booth: "Desasignar urna"
booths_title: "Listado de urnas asignadas"
officers_title: "Listado de presidentes de mesa asignados"
questions_title: "Listado de preguntas asignadas"
recounting_title: "Recuentos"
results_title: "Resultados"
remove_question: "Desasignar pregunta"
add_booth: "Asignar urna"
add_question: "Incluir pregunta"
add_officer_assignments: "Añadir turnos como presidente de mesa"
edit_officer_assignments: "Editar turnos"
search_results: "Resultados de la búsqueda"
no_search_results: "No se han encontrado resultados."
table_title: "Título"
table_assignment: "Asignación"
table_name: "Nombre"
table_location: "Ubicación"
table_email: "Email"
table_booth_name: "Urna"
table_final_recount: "Recuento final (presidente de mesa)"
table_recounts: "Recuentos diarios acumulados (presidente de mesa)"
table_whites: Papeletas en blanco
table_nulls: Papeletas nulas
table_answer: Respuesta
table_votes: Votos
flash:
question_added: "Pregunta añadida a esta votación"
error_on_question_added: "No se pudo asignar la pregunta"
@@ -377,6 +374,21 @@ es:
valid_answers: Respuestas válidas
description: Descripción
preview: Ver en la web
recounts:
index:
title: "Recuentos"
no_recounts: "No hay nada de lo que hacer recuento"
table_booth_name: "Urna"
table_recounts: "Recuentos diarios acumulados (presidente de mesa)"
table_final_recount: "Recuento final (presidente de mesa)"
results:
index:
title: "Resultados"
no_results: "No hay resultados"
table_whites: Papeletas en blanco
table_nulls: Papeletas nulas
table_answer: Respuesta
table_votes: Votos
booths:
index:
title: "Lista de urnas"
@@ -394,12 +406,6 @@ es:
submit_button: "Actualizar urna"
show:
location: "Ubicación"
booth_assignments:
flash:
destroy: "Urna desasignada"
create: "Urna asignada"
error_destroy: "Se ha producido un error al desasignar la urna"
error_create: "Se ha producido un error al intentar asignar la urna"
officials:
edit:
destroy: Eliminar condición de 'Cargo Público'
@@ -480,6 +486,8 @@ es:
user_search:
button: Buscar
placeholder: Buscar usuario por nombre o email
search_results: "Resultados de la búsqueda"
no_search_results: "No se han encontrado resultados."
spending_proposals:
index:
geozone_filter_all: Todos los ámbitos de actuación

View File

@@ -208,13 +208,21 @@ Rails.application.routes.draw do
scope module: :poll do
resources :polls do
get :search_booths, on: :member
get :search_officers, on: :member
get :search_questions, on: :member
patch :add_question, on: :member
patch :remove_question, on: :member
resources :booth_assignments, only: :show
resources :booth_assignments, only: [:index, :show, :create, :destroy] do
get :search_booths, on: :collection
end
resources :officer_assignments, only: [:index, :create, :destroy] do
get :search_officers, on: :collection
get :by_officer, on: :collection
end
resources :recounts, only: :index
resources :results, only: :index
end
resources :officers do
@@ -222,8 +230,6 @@ Rails.application.routes.draw do
end
resources :booths
resources :booth_assignments, only: [:create, :destroy]
resources :officer_assignments, only: [:index, :create, :destroy]
resources :questions
end

View File

@@ -54,7 +54,7 @@ feature 'Admin officer assignments in poll' do
booth = officer_assignment.booth_assignment.booth
officer = officer_assignment.officer
visit admin_officer_assignments_path(poll: poll, officer: 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
@@ -89,7 +89,7 @@ feature 'Admin officer assignments in poll' do
date: poll.ends_at,
count: 9876)
visit admin_officer_assignments_path(poll: poll, officer: officer)
visit by_officer_admin_poll_officer_assignments_path(poll, officer_id: officer.id)
within('#recount_list') { expect(page).to have_content('77') }
within('#final_recount_list') { expect(page).to have_content('9876') }

View File

@@ -175,8 +175,7 @@ feature 'Admin polls' do
visit admin_poll_path(poll)
click_link "Questions (1)"
expect(page).to have_content "Questions (1)"
expect(page).to have_content question.title
expect(page).to_not have_content other_question.title
expect(page).to_not have_content "There are no questions assigned to this poll"
@@ -187,10 +186,8 @@ feature 'Admin polls' do
question = create(:poll_question, poll: nil, title: 'Should we rebuild the city?')
visit admin_poll_path(poll)
within('#poll-resources') do
click_link 'Questions (0)'
end
expect(page).to have_content 'Questions (0)'
expect(page).to have_content 'There are no questions assigned to this poll'
fill_in 'search-questions', with: 'rebuild'
@@ -203,10 +200,8 @@ feature 'Admin polls' do
expect(page).to have_content 'Question added to this poll'
visit admin_poll_path(poll)
within('#poll-resources') do
click_link 'Questions (1)'
end
expect(page).to have_content 'Questions (1)'
expect(page).to_not have_content 'There are no questions assigned to this poll'
expect(page).to have_content question.title
end
@@ -216,10 +211,8 @@ feature 'Admin polls' do
question = create(:poll_question, poll: poll)
visit admin_poll_path(poll)
within('#poll-resources') do
click_link 'Questions (1)'
end
expect(page).to have_content 'Questions (1)'
expect(page).to_not have_content 'There are no questions assigned to this poll'
expect(page).to have_content question.title
@@ -230,10 +223,8 @@ feature 'Admin polls' do
expect(page).to have_content 'Question removed from this poll'
visit admin_poll_path(poll)
within('#poll-resources') do
click_link 'Questions (0)'
end
expect(page).to have_content 'Questions (0)'
expect(page).to have_content 'There are no questions assigned to this poll'
expect(page).to_not have_content question.title
end