mirror of
https://github.com/discourse/discourse.git
synced 2026-08-06 13:08:40 +08:00
The suspend user modal lists other accounts sharing the same IP address, with a checkbox next to each so staff can penalize them in the same action. Since #41227, every one of those checkboxes was disabled, making it impossible to select anyone. The modal enables a checkbox only when the user's `can_be_suspended` attribute is `true` in the similar-users response. That attribute regressed as a side effect of #41227: it added `can_be_suspended` to the parent `AdminUserListSerializer` behind an `include_can_be_suspended?` opt-in guard for the admin users list. `SimilarAdminUserSerializer` inherited that guard, and since the similar-users endpoint never passes the opt-in option, the attribute was silently dropped from its response — and a missing attribute reads as "cannot be suspended", disabling the checkbox. This change overrides the guard in `SimilarAdminUserSerializer` so the attribute is always serialized, as it was before. It also adds a request spec pinning `can_be_suspended`/`can_be_silenced` in the response, and extends the suspend system spec to tick a similar user's checkbox and verify both accounts get suspended — closing the coverage gap that let this regress unnoticed.
17 lines
317 B
Ruby
Vendored
17 lines
317 B
Ruby
Vendored
# frozen_string_literal: true
|
|
|
|
class SimilarAdminUserSerializer < AdminUserListSerializer
|
|
attributes :can_be_suspended, :can_be_silenced
|
|
|
|
def can_be_suspended
|
|
scope.can_suspend?(object)
|
|
end
|
|
|
|
def include_can_be_suspended?
|
|
true
|
|
end
|
|
|
|
def can_be_silenced
|
|
scope.can_silence_user?(object)
|
|
end
|
|
end
|