Enhance coverage for StatusPin
model (#32515)
This commit is contained in:
parent
9074c1fac9
commit
1edb527072
2 changed files with 94 additions and 58 deletions
|
@ -17,11 +17,17 @@ class StatusPin < ApplicationRecord
|
|||
|
||||
validates_with StatusPinValidator
|
||||
|
||||
after_destroy :invalidate_cleanup_info
|
||||
after_destroy :invalidate_cleanup_info, if: %i(account_matches_status_account? account_local?)
|
||||
|
||||
delegate :local?, to: :account, prefix: true
|
||||
|
||||
private
|
||||
|
||||
def invalidate_cleanup_info
|
||||
return unless status&.account_id == account_id && account.local?
|
||||
|
||||
account.statuses_cleanup_policy&.invalidate_last_inspected(status, :unpin)
|
||||
end
|
||||
|
||||
def account_matches_status_account?
|
||||
status&.account_id == account_id
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue