mirror of
https://github.com/discourse/discourse.git
synced 2024-11-23 06:04:11 +08:00
Don't include suspended_at or suspended_till unless suspended
This commit is contained in:
parent
dc2d9f05dc
commit
f73a3cc0d4
|
@ -655,7 +655,7 @@ class User < ActiveRecord::Base
|
|||
end
|
||||
|
||||
def suspended?
|
||||
suspended_till && suspended_till > DateTime.now
|
||||
!!(suspended_till && suspended_till > DateTime.now)
|
||||
end
|
||||
|
||||
def suspend_record
|
||||
|
|
|
@ -44,6 +44,14 @@ class AdminUserListSerializer < BasicUserSerializer
|
|||
object.suspended?
|
||||
end
|
||||
|
||||
def include_suspended_at?
|
||||
object.suspended?
|
||||
end
|
||||
|
||||
def include_suspended_till?
|
||||
object.suspended?
|
||||
end
|
||||
|
||||
def can_impersonate
|
||||
scope.can_impersonate?(object)
|
||||
end
|
||||
|
|
|
@ -125,6 +125,7 @@ describe Admin::UsersController do
|
|||
|
||||
it "works properly" do
|
||||
Fabricate(:api_key, user: user)
|
||||
expect(user).not_to be_suspended
|
||||
put(
|
||||
:suspend,
|
||||
params: {
|
||||
|
@ -137,6 +138,7 @@ describe Admin::UsersController do
|
|||
expect(response).to be_success
|
||||
|
||||
user.reload
|
||||
expect(user).to be_suspended
|
||||
expect(user.suspended_at).to be_present
|
||||
expect(user.suspended_till).to be_present
|
||||
expect(ApiKey.where(user_id: user.id).count).to eq(0)
|
||||
|
|
Loading…
Reference in New Issue
Block a user