From 0b14146f6ac16a519c51a1ce8d41830f16446aca Mon Sep 17 00:00:00 2001 From: evazion Date: Mon, 19 Aug 2019 18:48:44 -0500 Subject: [PATCH] posts: hotfix bug in /posts.json?tags=blah+order:random. --- app/logical/post_sets/post.rb | 2 +- test/functional/posts_controller_test.rb | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/app/logical/post_sets/post.rb b/app/logical/post_sets/post.rb index 6b44f8cf0..a2b291caa 100644 --- a/app/logical/post_sets/post.rb +++ b/app/logical/post_sets/post.rb @@ -137,7 +137,7 @@ module PostSets end # XXX HACK: uploader_name is needed in api responses and in data-uploader attribs (visible to mods only). - temp = temp.includes(:uploader) if format.to_sym != :html || CurrentUser.is_moderator? + temp = temp.includes(:uploader) if !is_random? && (format.to_sym != :html || CurrentUser.is_moderator?) temp.each # hack to force rails to eager load temp diff --git a/test/functional/posts_controller_test.rb b/test/functional/posts_controller_test.rb index 8b6d87c82..547585724 100644 --- a/test/functional/posts_controller_test.rb +++ b/test/functional/posts_controller_test.rb @@ -146,6 +146,9 @@ class PostsControllerTest < ActionDispatch::IntegrationTest get posts_path, params: { random: "1" } assert_response :success + + get posts_path(format: :json), params: { random: "1" } + assert_response :success end end end