adds booth info to poll show

This commit is contained in:
rgarcia
2016-09-28 12:34:24 +02:00
parent e97e7e20dc
commit 6387d28157
6 changed files with 88 additions and 52 deletions

View File

@@ -0,0 +1,18 @@
<tr id="booth_<%= booth.id %>" class="booth">
<td>
<strong>
<%= link_to booth.name, admin_poll_booth_path(@poll, booth) %>
</strong>
</td>
<td>
<%= booth.location %>
</td>
<td>
N <%= t("admin.booths.index.officers") %>
</td>
<td class="text-right">
<%= link_to t("admin.actions.edit"),
edit_admin_poll_booth_path(@poll, booth),
class: "button hollow" %>
</td>
</tr>

View File

@@ -20,7 +20,7 @@
<% end %>
<%= link_to t("admin.booths.index.add_booth"),
new_admin_poll_booth_path,
new_admin_poll_booth_path(@poll),
class: "button success" %>
<table>
@@ -32,24 +32,7 @@
</thead>
<tbody>
<% @booths.each do |booth| %>
<tr id="booth_<%= booth.id %>" class="booth">
<td>
<strong>
<%= link_to booth.name, admin_poll_booth_path(@poll, booth) %>
</strong>
</td>
<td>
<%= booth.location %>
</td>
<td>
N <%= t("admin.booths.index.officers") %>
</td>
<td class="text-right">
<%= link_to t("admin.actions.edit"),
edit_admin_poll_booth_path(@poll, booth),
class: "button hollow" %>
</td>
</tr>
<%= render partial: "booth", locals: { booth: booth } %>
<% end %>
</tbody>
</table>

View File

@@ -9,37 +9,28 @@
edit_admin_poll_path(@poll),
class: "button hollow float-right" %>
<%= link_to t("admin.polls.show.add_booth"), "#", class: "button success" %>
<%= link_to t("admin.polls.show.add_booth"),
new_admin_poll_booth_path(@poll),
class: "button success" %>
<!-- If booth in this poll == 0 -->
<div class="callout primary">
<%= t("admin.polls.show.no_booths") %>
</div>
<!-- else -->
<% if @poll.booths.empty? %>
<div class="callout primary">
<%= t("admin.polls.show.no_booths") %>
</div>
<% else %>
<h2><%= t("admin.polls.show.booths_title") %></h2>
<h2><%= t("admin.polls.show.booths_title") %></h2>
<table>
<thead>
<th><%= t("admin.polls.show.name") %></th>
<th><%= t("admin.polls.show.location") %></th>
<th>&nbsp;</th>
</thead>
<tbody>
<%= @poll.booths.each do |booth| %>
<tr>
<td>
<strong>
<%= link_to "Urna Moncloa (REFNUM)", "#" %>
</strong>
</td>
<td>
C/ Isaac Peral, 25. 28003, Madrid
</td>
<td class="text-right">
<%= link_to t("admin.actions.edit"), "#", class: "button hollow" %>
</td>
</tr>
<% end %>
</tbody>
</table>
<table>
<thead>
<th><%= t("admin.polls.show.name") %></th>
<th><%= t("admin.polls.show.location") %></th>
<th><%= t("admin.polls.show.officers") %></th>
<th>&nbsp;</th>
</thead>
<tbody>
<% @poll.booths.each do |booth| %>
<%= render partial: "admin/poll/booths/booth", locals: { booth: booth } %>
<% end %>
</tbody>
</table>
<% end %>

View File

@@ -179,6 +179,7 @@ en:
booths_title: "List of booths"
name: "Name"
location: "Location"
officers: "Officers"
booths:
index:
title: "List of booths"

View File

@@ -179,6 +179,7 @@ es:
booths_title: "Listado de urnas"
name: "Nombre"
location: "Ubicación"
officers: "Presidentes de mesa"
booths:
index:
title: "Lista de urnas"

View File

@@ -27,7 +27,8 @@ feature 'Admin polls' do
expect(page).to have_css ".poll", count: 3
Poll.all.each do |poll|
polls = Poll.all
polls.each do |poll|
within("#poll_#{poll.id}") do
expect(page).to have_content poll.name
end
@@ -79,4 +80,45 @@ feature 'Admin polls' do
expect(current_path).to eq(edit_admin_poll_path(poll))
end
context "Booths" do
context "Poll show" do
scenario "No booths" do
poll = create(:poll)
visit admin_poll_path(poll)
expect(page).to have_content "There are no booths in this poll."
end
scenario "Booth list" do
poll = create(:poll)
3.times { create(:poll_booth, poll: poll) }
visit admin_poll_path(poll)
expect(page).to have_css ".booth", count: 3
booths = Poll::Booth.all
booths.each do |booth|
within("#booth_#{booth.id}") do
expect(page).to have_content booth.name
expect(page).to have_content booth.location
end
end
expect(page).to_not have_content "There are no booths"
end
scenario "Add booth" do
poll = create(:poll)
visit admin_poll_path(poll)
click_link "Add booth"
expect(current_path).to eq(new_admin_poll_booth_path(poll))
expect(page).to have_content poll.name
end
end
end
end