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.
This commit is contained in:
Javi Martín
2020-04-15 15:00:32 +02:00
parent 6c0365d004
commit 37361a6f3d
2 changed files with 17 additions and 1 deletions

View File

@@ -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

View File

@@ -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