Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions app/jobs/family_reset_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ def perform(family, load_sample_data_for_email: nil)
family.categories.destroy_all
family.tags.destroy_all
family.merchants.destroy_all
family.recurring_transactions.destroy_all
family.plaid_items.destroy_all
family.imports.destroy_all
family.budgets.destroy_all
Expand Down
12 changes: 12 additions & 0 deletions test/fixtures/recurring_transactions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,15 @@ inactive_subscription:
next_expected_date: <%= 2.months.ago.to_date %>
status: inactive
occurrence_count: 2

manual_subscription:
family: dylan_family
name: "Gym Membership"
amount: 45.00
currency: USD
expected_day_of_month: 10
last_occurrence_date: <%= 1.month.ago.to_date %>
next_expected_date: <%= 20.days.from_now.to_date %>
status: active
occurrence_count: 5
manual: true
3 changes: 3 additions & 0 deletions test/jobs/family_reset_job_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,12 @@ class FamilyResetJobTest < ActiveJob::TestCase
test "resets family data successfully" do
initial_account_count = @family.accounts.count
initial_category_count = @family.categories.count
initial_recurring_count = @family.recurring_transactions.count

# Family should have existing data
assert initial_account_count > 0
assert initial_category_count > 0
assert initial_recurring_count > 0

# Don't expect Plaid removal calls since we're using fixtures without setup
@plaid_provider.stubs(:remove_item)
Expand All @@ -23,6 +25,7 @@ class FamilyResetJobTest < ActiveJob::TestCase
# All data should be removed
assert_equal 0, @family.accounts.reload.count
assert_equal 0, @family.categories.reload.count
assert_equal 0, @family.recurring_transactions.reload.count
end

test "resets family data even when Plaid credentials are invalid" do
Expand Down