FIX: Don’t translate TrustLevel name when generating links (#13588)

FIX: Don’t translate TrustLevel name when generating links (#13588)

We want to put the name of the trust level in to generated URLs, not the human-readable form.

i.e.:

/admin/users/list/newuser

rather than:

/admin/users/list/new user

diff --git a/app/models/concerns/reports/users_by_trust_level.rb b/app/models/concerns/reports/users_by_trust_level.rb
index 95cda80..ac2d1b9 100644
--- a/app/models/concerns/reports/users_by_trust_level.rb
+++ b/app/models/concerns/reports/users_by_trust_level.rb
@@ -24,7 +24,7 @@ module Reports::UsersByTrustLevel
       ]
 
       User.real.group('trust_level').count.sort.each do |level, count|
-        key = TrustLevel.name(level.to_i)
+        key = TrustLevel.levels.key(level.to_i)
         url = Proc.new { |k| "/admin/users/list/#{k}" }
         report.data << { url: url.call(key), key: key, x: level.to_i, y: count }
       end
diff --git a/spec/models/report_spec.rb b/spec/models/report_spec.rb
index 1611bb7..1c66288 100644
--- a/spec/models/report_spec.rb
+++ b/spec/models/report_spec.rb
@@ -352,6 +352,8 @@ describe Report do
         expect(report.data.find { |d| d[:x] == TrustLevel[0] }[:y]).to eq 3
         expect(report.data.find { |d| d[:x] == TrustLevel[2] }[:y]).to eq 2
         expect(report.data.find { |d| d[:x] == TrustLevel[4] }[:y]).to eq 1
+
+        expect(report.data.find { |d| d[:x] == TrustLevel[0] }[:url]).to eq '/admin/users/list/newuser'
       end
     end
   end

GitHub sha: 4728962f7d802de225a034dd691ad52092ff3d0f

This commit appears in #13588 which was approved by eviltrout. It was merged by jbrw.