Skip to content

Commit

Permalink
Allow deletion of users that favored projects
Browse files Browse the repository at this point in the history
  • Loading branch information
oliverguenther committed Dec 17, 2024
1 parent ec37288 commit d9c8489
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
5 changes: 5 additions & 0 deletions app/workers/principals/delete_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ def delete_associated(principal)
delete_notifications(principal)
delete_private_queries(principal)
delete_tokens(principal)
delete_favorites(principal)
end

def delete_notifications(principal)
Expand All @@ -77,6 +78,10 @@ def delete_private_queries(principal)
CostQuery.where(user_id: principal.id, is_public: false).delete_all
end

def delete_favorites(principal)
Favorite.where(user_id: principal.id).delete_all
end

def delete_tokens(principal)
::Token::Base.where(user_id: principal.id).destroy_all
end
Expand Down
11 changes: 11 additions & 0 deletions spec/workers/principals/delete_job_integration_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -475,6 +475,17 @@
it_behaves_like "cost_query handling"
it_behaves_like "project query handling"
it_behaves_like "mention rewriting"

describe "favorites" do
before do
project.add_favoring_user(principal)
job
end

it "removes the assigned_to association to the principal" do
expect(project.favoring_users.reload).to be_empty
end
end
end

context "with a group" do
Expand Down

0 comments on commit d9c8489

Please sign in to comment.