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`
This commit is contained in:
jbrw 2021-06-30 14:19:15 -04:00 committed by GitHub
parent 6209b11659
commit 4728962f7d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 1 deletions

View File

@ -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

View File

@ -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