From 21c7ff15fed56543026b1df363b3416eb0314aa8 Mon Sep 17 00:00:00 2001 From: rgarcia Date: Mon, 23 Oct 2017 21:34:28 +0200 Subject: [PATCH] fixes routes for poll's results and stats --- app/views/polls/_poll_group.html.erb | 8 ++++---- app/views/polls/_poll_subnav.html.erb | 4 ++-- config/routes.rb | 6 ++++-- spec/features/polls/polls_spec.rb | 20 ++++++++++---------- 4 files changed, 20 insertions(+), 18 deletions(-) diff --git a/app/views/polls/_poll_group.html.erb b/app/views/polls/_poll_group.html.erb index 9d83d5233..93174e157 100644 --- a/app/views/polls/_poll_group.html.erb +++ b/app/views/polls/_poll_group.html.erb @@ -21,9 +21,9 @@ <% poll.questions.each do |question| %>

<% if poll.results_enabled? %> - <%= link_to question.title, poll_results_path(poll) %> + <%= link_to question.title, results_poll_path(poll) %> <% elsif poll.stats_enabled? %> - <%= link_to question.title, poll_stats_path(poll) %> + <%= link_to question.title, stats_poll_path(poll) %> <% else %> <%= link_to question.title, poll %> <% end %> @@ -33,9 +33,9 @@ <% else %>

<% if poll.results_enabled? %> - <%= link_to poll.name, poll_results_path(poll) %> + <%= link_to poll.name, results_poll_path(poll) %> <% elsif poll.stats_enabled? %> - <%= link_to poll.name, poll_stats_path(poll) %> + <%= link_to poll.name, stats_poll_path(poll) %> <% else %> <%= link_to poll.name, poll %> <% end %> diff --git a/app/views/polls/_poll_subnav.html.erb b/app/views/polls/_poll_subnav.html.erb index 779c5c8d5..112f267ee 100644 --- a/app/views/polls/_poll_subnav.html.erb +++ b/app/views/polls/_poll_subnav.html.erb @@ -9,7 +9,7 @@

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

<% else %> -
  • <%= link_to t("polls.show.results_menu"), poll_results_path(@poll) %>
  • +
  • <%= link_to t("polls.show.results_menu"), results_poll_path(@poll) %>
  • <% end %> <% end %> @@ -19,7 +19,7 @@

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

    <% else %> -
  • <%= link_to t("polls.show.stats_menu"), poll_stats_path(@poll) %>
  • +
  • <%= link_to t("polls.show.stats_menu"), stats_poll_path(@poll) %>
  • <% end %> <% end %> diff --git a/config/routes.rb b/config/routes.rb index fe38eb9b4..5d54a7c3b 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -113,8 +113,10 @@ Rails.application.routes.draw do end resources :polls, only: [:show, :index] do - get :stats - get :results + member do + get :stats + get :results + end resources :questions, controller: 'polls/questions', shallow: true do post :answer, on: :member end diff --git a/spec/features/polls/polls_spec.rb b/spec/features/polls/polls_spec.rb index 82180cb23..8629a1087 100644 --- a/spec/features/polls/polls_spec.rb +++ b/spec/features/polls/polls_spec.rb @@ -65,7 +65,7 @@ feature 'Polls' do visit polls_path - expect(page).to have_link("Poll with stats", href: poll_stats_path(poll)) + expect(page).to have_link("Poll with stats", href: stats_poll_path(poll)) end scenario "Poll title link to results if enabled" do @@ -73,7 +73,7 @@ feature 'Polls' do visit polls_path - expect(page).to have_link("Poll with results", href: poll_results_path(poll)) + expect(page).to have_link("Poll with results", href: results_poll_path(poll)) end end @@ -395,10 +395,10 @@ feature 'Polls' do expect(page).to have_content("Poll results") expect(page).to have_content("Participation statistics") - visit poll_results_path(poll) + visit results_poll_path(poll) expect(page).to have_content("Questions") - visit poll_stats_path(poll) + visit stats_poll_path(poll) expect(page).to have_content("Participation data") end @@ -412,10 +412,10 @@ feature 'Polls' do expect(page).to_not have_content("Poll results") expect(page).to_not have_content("Participation statistics") - visit poll_results_path(poll) + visit results_poll_path(poll) expect(page).to have_content("You do not have permission to carry out the action 'results' on poll.") - visit poll_stats_path(poll) + visit stats_poll_path(poll) expect(page).to have_content("You do not have permission to carry out the action 'stats' on poll.") end @@ -429,10 +429,10 @@ feature 'Polls' do expect(page).to_not have_content("Poll results") expect(page).to_not have_content("Participation statistics") - visit poll_results_path(poll) + visit results_poll_path(poll) expect(page).to have_content("You do not have permission to carry out the action 'results' on poll.") - visit poll_stats_path(poll) + visit stats_poll_path(poll) expect(page).to have_content("You do not have permission to carry out the action 'stats' on poll.") end @@ -446,10 +446,10 @@ feature 'Polls' do expect(page).to have_content("Poll results") expect(page).to have_content("Participation statistics") - visit poll_results_path(poll) + visit results_poll_path(poll) expect(page).to have_content("Questions") - visit poll_stats_path(poll) + visit stats_poll_path(poll) expect(page).to have_content("Participation data") end end