Generate navigation links for polls without a slug

This commit is contained in:
Javi Martín
2019-05-21 13:04:21 +02:00
parent 3d84920c47
commit e461c8d0ac
2 changed files with 18 additions and 3 deletions

View File

@@ -8,7 +8,7 @@
<h2><%= t("polls.show.results_menu") %></h2>
</li>
<% else %>
<li><%= link_to t("polls.show.results_menu"), results_poll_path(id: @poll.slug) %></li>
<li><%= link_to t("polls.show.results_menu"), results_poll_path(id: @poll.slug || @poll.id) %></li>
<% end %>
<% end %>
@@ -18,7 +18,7 @@
<h2><%= t("polls.show.stats_menu") %></h2>
</li>
<% else %>
<li><%= link_to t("polls.show.stats_menu"), stats_poll_path(id: @poll.slug) %></li>
<li><%= link_to t("polls.show.stats_menu"), stats_poll_path(id: @poll.slug || @poll.id) %></li>
<% end %>
<% end %>
@@ -27,7 +27,7 @@
<h2><%= t("polls.show.info_menu") %></h2>
</li>
<% else %>
<li><%= link_to t("polls.show.info_menu"), poll_path(id: @poll.slug) %></li>
<li><%= link_to t("polls.show.info_menu"), poll_path(id: @poll.slug || @poll.id) %></li>
<% end %>
</ul>
</div>

View File

@@ -492,5 +492,20 @@ feature "Polls" do
expect(page).not_to have_content("Poll results")
expect(page).not_to have_content("Participation statistics")
end
scenario "Generates navigation links for polls without a slug" do
poll = create(:poll, :expired, results_enabled: true, stats_enabled: true)
poll.update_column(:slug, nil)
visit poll_path(poll)
expect(page).to have_link "Participation statistics"
expect(page).to have_link "Poll results"
click_link "Poll results"
expect(page).to have_link "Information"
end
end
end