From 9fbd7eec8fa4aa11ae5f8502519747a62cb615b8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javi=20Mart=C3=ADn?= Date: Tue, 14 May 2024 00:59:01 +0200 Subject: [PATCH] Remove obsolete routes for poll questions The routes for poll questions were accidentally deleted in commit 5bb831e9595 when deleting the `:show` action, and restored in commit 9871503c5e8. However, the deleted code was: ``` resources :questions, only: [:show], controller: 'polls/questions' (...) ``` While the restored code was: ``` resources :questions, controller: 'polls/questions' (...) ``` Meaning we forgot to add the `only: []` option when restoring the routes. We also forgot to remove the `before_action` code when deleting the `:show` action, so we're removing it now. --- app/controllers/polls/questions_controller.rb | 2 -- config/routes/poll.rb | 2 +- spec/routing/polymorphic_routes_spec.rb | 6 ------ 3 files changed, 1 insertion(+), 9 deletions(-) diff --git a/app/controllers/polls/questions_controller.rb b/app/controllers/polls/questions_controller.rb index 0e7f9a1c9..3db380663 100644 --- a/app/controllers/polls/questions_controller.rb +++ b/app/controllers/polls/questions_controller.rb @@ -2,8 +2,6 @@ class Polls::QuestionsController < ApplicationController load_and_authorize_resource :poll load_and_authorize_resource :question, class: "Poll::Question" - has_orders %w[most_voted newest oldest], only: :show - def answer answer = @question.find_or_initialize_user_answer(current_user, params[:answer]) answer.save_and_record_voter_participation diff --git a/config/routes/poll.rb b/config/routes/poll.rb index 94cf504b4..d33e75923 100644 --- a/config/routes/poll.rb +++ b/config/routes/poll.rb @@ -4,7 +4,7 @@ resources :polls, only: [:show, :index] do get :results end - resources :questions, controller: "polls/questions", shallow: true do + resources :questions, controller: "polls/questions", shallow: true, only: [] do post :answer, on: :member resources :answers, controller: "polls/answers", only: :destroy, shallow: false end diff --git a/spec/routing/polymorphic_routes_spec.rb b/spec/routing/polymorphic_routes_spec.rb index c39b986d5..cf2e748dd 100644 --- a/spec/routing/polymorphic_routes_spec.rb +++ b/spec/routing/polymorphic_routes_spec.rb @@ -53,12 +53,6 @@ describe "Polymorphic routes" do ) end - it "routes poll questions" do - question = create(:poll_question) - - expect(polymorphic_path(question)).to eq question_path(question) - end - it "routes topics" do community = create(:proposal).community topic = create(:topic, community: community)