From 37361a6f3d333934336a1ef1ae786196bf82da39 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javi=20Mart=C3=ADn?= Date: Wed, 15 Apr 2020 15:00:32 +0200 Subject: [PATCH] Replace render :nothing with head :ok Using `render :nothing` was deprecated, but we never noticed it because we didn't have a test for the action using it. In Rails 5.1, it raises an exception. Using `head :ok` and adding a test for this scenario solves the issue. --- .../admin/poll/questions/answers_controller.rb | 2 +- .../admin/poll/questions/answers/answers_spec.rb | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/app/controllers/admin/poll/questions/answers_controller.rb b/app/controllers/admin/poll/questions/answers_controller.rb index 7b56de3c1..c75524a60 100644 --- a/app/controllers/admin/poll/questions/answers_controller.rb +++ b/app/controllers/admin/poll/questions/answers_controller.rb @@ -44,7 +44,7 @@ class Admin::Poll::Questions::AnswersController < Admin::Poll::BaseController def order_answers ::Poll::Question::Answer.order_answers(params[:ordered_list]) - render nothing: true + head :ok end private diff --git a/spec/system/admin/poll/questions/answers/answers_spec.rb b/spec/system/admin/poll/questions/answers/answers_spec.rb index fdd1a4863..395a1bed3 100644 --- a/spec/system/admin/poll/questions/answers/answers_spec.rb +++ b/spec/system/admin/poll/questions/answers/answers_spec.rb @@ -58,4 +58,20 @@ describe "Answers" do expect("Another title").to appear_before("New title") end + + scenario "Reorder", :js do + question = create(:poll_question) + create(:poll_question_answer, question: question, title: "First", given_order: 1) + create(:poll_question_answer, question: question, title: "Last", given_order: 2) + + visit admin_question_path(question) + + within("tbody.sortable") do + expect("First").to appear_before("Last") + + find("tr", text: "Last").drag_to(find("tr", text: "First")) + + expect("Last").to appear_before("First") + end + end end