diff --git a/app/models/user.rb b/app/models/user.rb index 2429418648a..c70890af63e 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -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 diff --git a/app/serializers/admin_user_list_serializer.rb b/app/serializers/admin_user_list_serializer.rb index ba3953e5bb5..b4f4d60037d 100644 --- a/app/serializers/admin_user_list_serializer.rb +++ b/app/serializers/admin_user_list_serializer.rb @@ -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 diff --git a/spec/controllers/admin/users_controller_spec.rb b/spec/controllers/admin/users_controller_spec.rb index f1ac0aa408d..64dbb1060bd 100644 --- a/spec/controllers/admin/users_controller_spec.rb +++ b/spec/controllers/admin/users_controller_spec.rb @@ -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)