diff --git a/app/models/user.rb b/app/models/user.rb index 54dc890b..b246c4a9 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -234,7 +234,10 @@ class User < ApplicationRecord end def unban - UseCase::User::Unban.call(id) + UserBan.current.where(user_id: self.id).update_all( + # -1s to account for flakyness with timings in tests + expires_at: DateTime.now - 1.second + ) end # Bans a user. diff --git a/lib/use_case/user/unban.rb b/lib/use_case/user/unban.rb index 81c5ca1c..a1f191e1 100644 --- a/lib/use_case/user/unban.rb +++ b/lib/use_case/user/unban.rb @@ -8,10 +8,11 @@ module UseCase param :target_user_id, type: Types::Coercible::Integer def call - UserBan.current.where(user_id: target_user_id).update_all( - # -1s to account for flakyness with timings in tests - expires_at: DateTime.now - 1.second - ) + target_user.unban + end + + def target_user + @target_user ||= ::User.find(target_user_id) end end end