Delete pins belonging to cards in a board with revoked access

As part of cleaning up inaccessible data in the board after revoking
access.
This commit is contained in:
Rosa Gutierrez
2026-01-13 13:12:22 +01:00
committed by Rosa Gutierrez
parent 829dd345f6
commit 5e099c4c06
2 changed files with 28 additions and 0 deletions
+5
View File
@@ -46,6 +46,7 @@ module Board::Accessible
mentions_for_user(user).destroy_all
notifications_for_user(user).destroy_all
watches_for(user).destroy_all
pins_for(user).destroy_all
end
def watchers
@@ -99,4 +100,8 @@ module Board::Accessible
def watches_for(user)
Watch.where(card: cards, user: user)
end
def pins_for(user)
Pin.where(card: cards, user: user)
end
end
+23
View File
@@ -80,4 +80,27 @@ class AccessTest < ActiveSupport::TestCase
assert_not card.watched_by?(kevin)
end
test "pins are destroyed when access is lost" do
kevin = users(:kevin)
board = boards(:writebook)
card = cards(:logo) # Kevin has pinned this card
other_board = boards(:miltons_wish_list)
other_card = cards(:radio)
other_board.accesses.grant_to(kevin)
other_card.pin_by(kevin)
assert card.pinned_by?(kevin)
assert other_card.pinned_by?(kevin)
kevin_access = accesses(:writebook_kevin)
perform_enqueued_jobs only: Board::CleanInaccessibleDataJob do
kevin_access.destroy
end
assert_not card.pinned_by?(kevin)
assert other_card.pinned_by?(kevin), "Pin on other board should not be destroyed"
end
end