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:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user