fixes routes for poll's results and stats

This commit is contained in:
rgarcia
2017-10-23 21:34:28 +02:00
parent ca63e4998f
commit 21c7ff15fe
4 changed files with 20 additions and 18 deletions

View File

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

View File

@@ -9,7 +9,7 @@
<h2><%= t("polls.show.results_menu") %></h2> <h2><%= t("polls.show.results_menu") %></h2>
</li> </li>
<% else %> <% else %>
<li><%= link_to t("polls.show.results_menu"), poll_results_path(@poll) %></li> <li><%= link_to t("polls.show.results_menu"), results_poll_path(@poll) %></li>
<% end %> <% end %>
<% end %> <% end %>
@@ -19,7 +19,7 @@
<h2><%= t("polls.show.stats_menu") %></h2> <h2><%= t("polls.show.stats_menu") %></h2>
</li> </li>
<% else %> <% else %>
<li><%= link_to t("polls.show.stats_menu"), poll_stats_path(@poll) %></li> <li><%= link_to t("polls.show.stats_menu"), stats_poll_path(@poll) %></li>
<% end %> <% end %>
<% end %> <% end %>

View File

@@ -113,8 +113,10 @@ Rails.application.routes.draw do
end end
resources :polls, only: [:show, :index] do resources :polls, only: [:show, :index] do
get :stats member do
get :results get :stats
get :results
end
resources :questions, controller: 'polls/questions', shallow: true do resources :questions, controller: 'polls/questions', shallow: true do
post :answer, on: :member post :answer, on: :member
end end

View File

@@ -65,7 +65,7 @@ feature 'Polls' do
visit polls_path 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 end
scenario "Poll title link to results if enabled" do scenario "Poll title link to results if enabled" do
@@ -73,7 +73,7 @@ feature 'Polls' do
visit polls_path 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
end end
@@ -395,10 +395,10 @@ feature 'Polls' do
expect(page).to have_content("Poll results") expect(page).to have_content("Poll results")
expect(page).to have_content("Participation statistics") expect(page).to have_content("Participation statistics")
visit poll_results_path(poll) visit results_poll_path(poll)
expect(page).to have_content("Questions") expect(page).to have_content("Questions")
visit poll_stats_path(poll) visit stats_poll_path(poll)
expect(page).to have_content("Participation data") expect(page).to have_content("Participation data")
end end
@@ -412,10 +412,10 @@ feature 'Polls' do
expect(page).to_not have_content("Poll results") expect(page).to_not have_content("Poll results")
expect(page).to_not have_content("Participation statistics") 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.") 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.") expect(page).to have_content("You do not have permission to carry out the action 'stats' on poll.")
end end
@@ -429,10 +429,10 @@ feature 'Polls' do
expect(page).to_not have_content("Poll results") expect(page).to_not have_content("Poll results")
expect(page).to_not have_content("Participation statistics") 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.") 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.") expect(page).to have_content("You do not have permission to carry out the action 'stats' on poll.")
end end
@@ -446,10 +446,10 @@ feature 'Polls' do
expect(page).to have_content("Poll results") expect(page).to have_content("Poll results")
expect(page).to have_content("Participation statistics") expect(page).to have_content("Participation statistics")
visit poll_results_path(poll) visit results_poll_path(poll)
expect(page).to have_content("Questions") expect(page).to have_content("Questions")
visit poll_stats_path(poll) visit stats_poll_path(poll)
expect(page).to have_content("Participation data") expect(page).to have_content("Participation data")
end end
end end