Files
ubicloud/spec/model/account_spec.rb
Jeremy Evans 046c5a10ea Add {Subject,Object}Tag::Cleanup modules
These can be included in other classes so the related tag
memberships and access control entries are deleted when the
object is destroyed.

It's possible to do this by defining associations and using
association_dependencies, but defining unnecessary associations
is a bad idea from a memory usage standpoint, and this approach
should be simpler and more efficient.
2025-01-09 09:55:55 -08:00

16 lines
600 B
Ruby

# frozen_string_literal: true
RSpec.describe Account do
it "removes referencing access control entries and subject tag memberships" do
account = described_class.create_with_id(email: "test@example.com")
project = account.create_project_with_default_policy("project-1", default_policy: false)
tag = SubjectTag.create_with_id(project_id: project.id, name: "t")
tag.add_member(account.id)
ace = AccessControlEntry.create_with_id(project_id: project.id, subject_id: account.id)
account.destroy
expect(tag.member_ids).to be_empty
expect(ace).not_to be_exists
end
end