tweaks admin/polls pages and specs

This commit is contained in:
Juanjo Bazán
2016-12-06 13:51:14 +01:00
parent e8ccc07273
commit 60e7ac20e7
7 changed files with 59 additions and 44 deletions

View File

@@ -59,7 +59,7 @@
<span class="icon-checkmark-circle"></span>
<strong><%= t("admin.menu.title_polls") %></strong>
</a>
<ul <%= "class=is-active" if menu_polls %>>
<ul id="polls_menu" <%= "class=is-active" if menu_polls %>>
<li <%= 'class=active' if controller_name == 'polls' %>>
<%= link_to t('admin.menu.polls'), admin_polls_path %>
</li>

View File

@@ -12,12 +12,25 @@
<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 } %>
<tr id="booth_<%= booth.id %>" class="booth">
<td>
<strong>
<%= link_to booth.name, admin_booth_path(booth) %>
</strong>
</td>
<td>
<%= booth.location %>
</td>
<td class="text-right">
<%= link_to t("admin.polls.show.remove_booth"),
"#",
class: "button hollow alert" %>
</td>
</tr>
<% end %>
</tbody>
</table>

View File

@@ -2,11 +2,11 @@
<div class="small-12 column">
<% if @poll.officers.empty? %>
<div class="callout primary text-center">
<%= t("admin.polls.show.no_booths") %>
<%= t("admin.polls.show.no_officers") %>
</div>
<% else %>
<h2><%= t("admin.polls.show.booths_title") %></h2>
<h2><%= t("admin.polls.show.officers_title") %></h2>
<table>
<thead>

View File

@@ -3,27 +3,28 @@
<%= link_to "Añadir pregunta",
new_admin_question_path(poll_id: @poll.id),
class: "button success" %>
<% if @poll.questions.empty? %>
<div class="callout primary text-center">
<%= t('admin.polls.show.no_questions') %>
</div>
<% else %>
<table>
<% @poll.questions.each do |question| %>
<tr id="<%= dom_id(question) %>">
<td><%= link_to question.title, admin_question_path(question) %></td>
<td class="text-right">
<%= link_to t('shared.edit'),
edit_admin_question_path(question),
class: "button hollow" %>
<%= link_to t('shared.delete'),
admin_question_path(question),
class: "button hollow alert",
method: :delete %>
</td>
</tr>
<% end %>
</table>
<% end %>
</div>
<% if @poll.questions.count == 0 %>
<div class="callout primary text-center">
<%= t('admin.questions.index.no_questions') %>
</div>
<% else %>
<table>
<% @poll.questions.each do |question| %>
<tr id="<%= dom_id(question) %>">
<td><%= link_to question.title, admin_question_path(question) %></td>
<td class="text-right">
<%= link_to t('shared.edit'),
edit_admin_question_path(question),
class: "button hollow" %>
<%= link_to t('shared.delete'),
admin_question_path(question),
class: "button hollow alert",
method: :delete %>
</td>
</tr>
<% end %>
</table>
<% end %>
</div>

View File

@@ -179,7 +179,10 @@ en:
booths_tab: Booths
officers_tab: Officers
no_booths: "There are no booths in this poll."
no_questions: "There are no questions assigned to this poll yet."
no_officers: "There are no officers assigned to this poll."
add_booth: "Add booth"
remove_booth: "Remove booth from poll"
booths_title: "List of booths"
name: "Name"
location: "Location"

View File

@@ -179,7 +179,10 @@ es:
booths_tab: Urnas
officers_tab: Presidentes de mesa
no_booths: "No hay urnas en esta votación."
no_questions: "No hay preguntas asignadas a esta votación todavía."
no_officers: "No hay presidentes de mesa asignados."
add_booth: "Añadir urna"
remove_booth: "Deasignar urna"
booths_title: "Listado de urnas"
name: "Nombre"
location: "Ubicación"

View File

@@ -7,21 +7,24 @@ feature 'Admin polls' do
login_as(admin.user)
end
scenario 'Index empty' do
scenario 'Index empty', :js do
visit admin_root_path
within('#side_menu') do
click_link "Polls"
within('#polls_menu') do
click_link "Polls"
end
expect(page).to have_content "There are no polls"
end
scenario 'Index' do
scenario 'Index', :js do
3.times { create(:poll) }
visit admin_root_path
within('#side_menu') do
click_link "Polls"
within('#polls_menu') do
click_link "Polls"
end
@@ -84,18 +87,20 @@ feature 'Admin polls' do
context "Poll show" do
scenario "No booths" do
scenario "No booths", :js do
poll = create(:poll)
visit admin_poll_path(poll)
click_link "Booths (0)"
expect(page).to have_content "There are no booths in this poll."
end
scenario "Booth list" do
scenario "Booth list", :js do
poll = create(:poll)
3.times { create(:poll_booth, poll: poll) }
3.times { create(:poll_booth, polls: [poll]) }
visit admin_poll_path(poll)
click_link "Booths (3)"
expect(page).to have_css ".booth", count: 3
@@ -108,16 +113,6 @@ feature 'Admin polls' do
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