mirror of
https://github.com/glitch-soc/mastodon.git
synced 2025-12-15 16:59:41 +00:00
Add coverage for ListAccount follow/follow_request set up (#31896)
This commit is contained in:
@@ -20,13 +20,11 @@ class ListAccount < ApplicationRecord
|
||||
validates :account_id, uniqueness: { scope: :list_id }
|
||||
validate :validate_relationship
|
||||
|
||||
before_validation :set_follow
|
||||
before_validation :set_follow, unless: :list_owner_account_is_account?
|
||||
|
||||
private
|
||||
|
||||
def set_follow
|
||||
return if list.account_id == account.id
|
||||
|
||||
self.follow = Follow.find_by!(account_id: list.account_id, target_account_id: account.id)
|
||||
rescue ActiveRecord::RecordNotFound
|
||||
self.follow_request = FollowRequest.find_by!(account_id: list.account_id, target_account_id: account.id)
|
||||
@@ -39,4 +37,8 @@ class ListAccount < ApplicationRecord
|
||||
errors.add(:follow, 'mismatched accounts') if follow_id.present? && follow.target_account_id != account_id
|
||||
errors.add(:follow_request, 'mismatched accounts') if follow_request_id.present? && follow_request.target_account_id != account_id
|
||||
end
|
||||
|
||||
def list_owner_account_is_account?
|
||||
list.account_id == account_id
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user