diff --git a/app/controllers/comments_controller.rb b/app/controllers/comments_controller.rb index f6f69f0f9..89ccf17b3 100644 --- a/app/controllers/comments_controller.rb +++ b/app/controllers/comments_controller.rb @@ -5,7 +5,7 @@ class CommentsController < ApplicationController skip_before_action :api_check def index - params[:group_by] ||= "comment" if params[:search] + params[:group_by] ||= "comment" if params[:search].present? if params[:group_by] == "comment" || request.format == Mime::Type.lookup("application/atom+xml") index_by_comment diff --git a/test/functional/comments_controller_test.rb b/test/functional/comments_controller_test.rb index 72e79f2e6..7bde760d6 100644 --- a/test/functional/comments_controller_test.rb +++ b/test/functional/comments_controller_test.rb @@ -21,8 +21,10 @@ class CommentsControllerTest < ActionDispatch::IntegrationTest context "index action" do context "grouped by post" do should "render all comments for .js" do - get comments_path(post_id: @post.id, group_by: "post", format: "js"), xhr: true + get comments_path(post_id: @post.id), xhr: true + assert_response :success + assert_equal("text/javascript", response.media_type) end should "show posts with visible comments" do