diff --git a/app/views/admin/poll/booths/_booth.html.erb b/app/views/admin/poll/booths/_booth.html.erb
new file mode 100644
index 000000000..ff1683867
--- /dev/null
+++ b/app/views/admin/poll/booths/_booth.html.erb
@@ -0,0 +1,18 @@
+
+ |
+
+ <%= link_to booth.name, admin_poll_booth_path(@poll, booth) %>
+
+ |
+
+ <%= booth.location %>
+ |
+
+ N <%= t("admin.booths.index.officers") %>
+ |
+
+ <%= link_to t("admin.actions.edit"),
+ edit_admin_poll_booth_path(@poll, booth),
+ class: "button hollow" %>
+ |
+
\ No newline at end of file
diff --git a/app/views/admin/poll/booths/index.html.erb b/app/views/admin/poll/booths/index.html.erb
index b3733670d..d2a9a7e5a 100644
--- a/app/views/admin/poll/booths/index.html.erb
+++ b/app/views/admin/poll/booths/index.html.erb
@@ -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" %>
@@ -32,24 +32,7 @@
<% @booths.each do |booth| %>
-
- |
-
- <%= link_to booth.name, admin_poll_booth_path(@poll, booth) %>
-
- |
-
- <%= booth.location %>
- |
-
- N <%= t("admin.booths.index.officers") %>
- |
-
- <%= link_to t("admin.actions.edit"),
- edit_admin_poll_booth_path(@poll, booth),
- class: "button hollow" %>
- |
-
+ <%= render partial: "booth", locals: { booth: booth } %>
<% end %>
diff --git a/app/views/admin/poll/polls/show.html.erb b/app/views/admin/poll/polls/show.html.erb
index 8a02ebfd7..bed01af41 100644
--- a/app/views/admin/poll/polls/show.html.erb
+++ b/app/views/admin/poll/polls/show.html.erb
@@ -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" %>
-
-
- <%= t("admin.polls.show.no_booths") %>
-
-
+<% if @poll.booths.empty? %>
+
+ <%= t("admin.polls.show.no_booths") %>
+
+<% else %>
+ <%= t("admin.polls.show.booths_title") %>
-<%= t("admin.polls.show.booths_title") %>
-
-
-
- | <%= t("admin.polls.show.name") %> |
- <%= t("admin.polls.show.location") %> |
- |
-
-
- <%= @poll.booths.each do |booth| %>
-
- |
-
- <%= link_to "Urna Moncloa (REFNUM)", "#" %>
-
- |
-
- C/ Isaac Peral, 25. 28003, Madrid
- |
-
- <%= link_to t("admin.actions.edit"), "#", class: "button hollow" %>
- |
-
- <% end %>
-
-
+
+
+ | <%= t("admin.polls.show.name") %> |
+ <%= t("admin.polls.show.location") %> |
+ <%= t("admin.polls.show.officers") %> |
+ |
+
+
+ <% @poll.booths.each do |booth| %>
+ <%= render partial: "admin/poll/booths/booth", locals: { booth: booth } %>
+ <% end %>
+
+
+<% end %>
\ No newline at end of file
diff --git a/config/locales/admin.en.yml b/config/locales/admin.en.yml
index db4cf34ca..ef294262d 100755
--- a/config/locales/admin.en.yml
+++ b/config/locales/admin.en.yml
@@ -179,6 +179,7 @@ en:
booths_title: "List of booths"
name: "Name"
location: "Location"
+ officers: "Officers"
booths:
index:
title: "List of booths"
diff --git a/config/locales/admin.es.yml b/config/locales/admin.es.yml
index 6023da712..48dfe2959 100644
--- a/config/locales/admin.es.yml
+++ b/config/locales/admin.es.yml
@@ -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"
diff --git a/spec/features/admin/poll/polls_spec.rb b/spec/features/admin/poll/polls_spec.rb
index bab7b5847..80f875567 100644
--- a/spec/features/admin/poll/polls_spec.rb
+++ b/spec/features/admin/poll/polls_spec.rb
@@ -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
\ No newline at end of file