1
0
Fork 0
mirror of https://github.com/maybe-finance/maybe.git synced 2025-07-19 13:19:39 +02:00

Feat: Data "reset" button (#1913)

* feat: Allow admins to delete family data

* feat: Allow self-hosting users to delete cached data

* Remove system tests
This commit is contained in:
Tony Vincent 2025-02-28 13:49:12 +01:00 committed by GitHub
parent f7064fd4dd
commit 8208722247
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
13 changed files with 206 additions and 16 deletions

View file

@ -31,6 +31,41 @@ class UsersControllerTest < ActionDispatch::IntegrationTest
assert_equal "Your profile has been updated.", flash[:notice]
end
test "admin can reset family data" do
account = accounts(:investment)
category = categories(:income)
tag = tags(:one)
merchant = merchants(:netflix)
import = imports(:transaction)
budget = budgets(:one)
plaid_item = plaid_items(:one)
perform_enqueued_jobs(only: FamilyResetJob) do
delete reset_user_url(@user)
end
assert_redirected_to settings_profile_url
assert_equal I18n.t("users.reset.success"), flash[:notice]
assert_not Account.exists?(account.id)
assert_not Category.exists?(category.id)
assert_not Tag.exists?(tag.id)
assert_not Merchant.exists?(merchant.id)
assert_not Import.exists?(import.id)
assert_not Budget.exists?(budget.id)
assert_not PlaidItem.exists?(plaid_item.id)
end
test "non-admin cannot reset family data" do
sign_in @member = users(:family_member)
delete reset_user_url(@member)
assert_redirected_to settings_profile_url
assert_equal I18n.t("users.reset.unauthorized"), flash[:alert]
assert_no_enqueued_jobs only: FamilyResetJob
end
test "member can deactivate their account" do
sign_in @member = users(:family_member)
delete user_url(@member)