From e461c8d0acc2cbcbc4c5030a155d188e28894b60 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javi=20Mart=C3=ADn?= Date: Tue, 21 May 2019 13:04:21 +0200 Subject: [PATCH] Generate navigation links for polls without a slug --- app/views/polls/_poll_subnav.html.erb | 6 +++--- spec/features/polls/polls_spec.rb | 15 +++++++++++++++ 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/app/views/polls/_poll_subnav.html.erb b/app/views/polls/_poll_subnav.html.erb index 28340b9b6..e50d64e0a 100644 --- a/app/views/polls/_poll_subnav.html.erb +++ b/app/views/polls/_poll_subnav.html.erb @@ -8,7 +8,7 @@

<%= t("polls.show.results_menu") %>

<% else %> -
  • <%= link_to t("polls.show.results_menu"), results_poll_path(id: @poll.slug) %>
  • +
  • <%= link_to t("polls.show.results_menu"), results_poll_path(id: @poll.slug || @poll.id) %>
  • <% end %> <% end %> @@ -18,7 +18,7 @@

    <%= t("polls.show.stats_menu") %>

    <% else %> -
  • <%= link_to t("polls.show.stats_menu"), stats_poll_path(id: @poll.slug) %>
  • +
  • <%= link_to t("polls.show.stats_menu"), stats_poll_path(id: @poll.slug || @poll.id) %>
  • <% end %> <% end %> @@ -27,7 +27,7 @@

    <%= t("polls.show.info_menu") %>

    <% else %> -
  • <%= link_to t("polls.show.info_menu"), poll_path(id: @poll.slug) %>
  • +
  • <%= link_to t("polls.show.info_menu"), poll_path(id: @poll.slug || @poll.id) %>
  • <% end %> diff --git a/spec/features/polls/polls_spec.rb b/spec/features/polls/polls_spec.rb index 77abe0100..f9c420076 100644 --- a/spec/features/polls/polls_spec.rb +++ b/spec/features/polls/polls_spec.rb @@ -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