]> cat aescling's git repositories - mastodon.git/commitdiff
Fix /admin/tags/:id crashing since Rails 6.1 update (#15953)
authorClaire <claire.github-309c@sitedethib.com>
Fri, 26 Mar 2021 17:36:16 +0000 (18:36 +0100)
committerGitHub <noreply@github.com>
Fri, 26 Mar 2021 17:36:16 +0000 (18:36 +0100)
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
spec/controllers/admin/tags_controller_spec.rb

index 59df4470e611b2baf754f49ce4fb129bc4c4b726..eed4feea2f530056de2723e20d0d828990b6120e 100644 (file)
@@ -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
index 5c1944fc770dcd225dca79d48db20abc22804818..9145d887dea52a80bee7cbda6bcb19d1b94e4486 100644 (file)
@@ -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