From a650a1157d5b71bc5718759643fe5bb572b16a8b Mon Sep 17 00:00:00 2001 From: Claire Date: Fri, 26 Mar 2021 18:36:16 +0100 Subject: [PATCH] Fix /admin/tags/:id crashing since Rails 6.1 update (#15953) Raw SQL passed to `pluck` now has to be explicitly marked as SQL via Arel.sql, see https://github.com/rails/rails/pull/27947 --- app/controllers/admin/tags_controller.rb | 4 ++-- spec/controllers/admin/tags_controller_spec.rb | 12 ++++++++++++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/app/controllers/admin/tags_controller.rb b/app/controllers/admin/tags_controller.rb index 59df4470e..eed4feea2 100644 --- a/app/controllers/admin/tags_controller.rb +++ b/app/controllers/admin/tags_controller.rb @@ -59,8 +59,8 @@ module Admin .where(Status.arel_table[:id].gteq(Mastodon::Snowflake.id_at(Time.now.utc.beginning_of_day))) .joins(:account) .group('accounts.domain') - .reorder('statuses_count desc') - .pluck('accounts.domain, count(*) AS statuses_count') + .reorder(statuses_count: :desc) + .pluck(Arel.sql('accounts.domain, count(*) AS statuses_count')) end def set_counters diff --git a/spec/controllers/admin/tags_controller_spec.rb b/spec/controllers/admin/tags_controller_spec.rb index 5c1944fc7..9145d887d 100644 --- a/spec/controllers/admin/tags_controller_spec.rb +++ b/spec/controllers/admin/tags_controller_spec.rb @@ -20,4 +20,16 @@ RSpec.describe Admin::TagsController, type: :controller do expect(response).to have_http_status(200) end end + + describe 'GET #show' do + let!(:tag) { Fabricate(:tag) } + + before do + get :show, params: { id: tag.id } + end + + it 'returns status 200' do + expect(response).to have_http_status(200) + end + end end