mirror of
https://github.com/we-promise/sure.git
synced 2026-06-01 16:59:03 +00:00
generate_goals! now also seeds a fully-populated Goal::Retirement for the demo family admin: a DE GRV state pension + a bAV lump-plus-annuity source, three years of Renteninformation statements, two adjustments (mortgage paid off, higher healthcare), and the first two investment accounts in the bucket — so the dashboard renders with real numbers out of the box. Idempotent + best-effort (never breaks demo generation). Tested against a fixture family.
26 lines
945 B
Ruby
26 lines
945 B
Ruby
require "test_helper"
|
|
|
|
class Demo::GeneratorTest < ActiveSupport::TestCase
|
|
test "generate_retirement! seeds a populated plan for the family owner" do
|
|
family = families(:empty)
|
|
assert_not family.goals.where(type: "Goal::Retirement").exists?
|
|
|
|
Demo::Generator.new.send(:generate_retirement!, family)
|
|
|
|
plan = family.goals.find_by(type: "Goal::Retirement")
|
|
assert plan, "expected a Goal::Retirement to be created"
|
|
assert_equal family.users.order(:created_at).first.id, plan.user_id
|
|
assert_equal 2, plan.pension_sources.count
|
|
assert_equal 3, plan.statements.count
|
|
assert_equal 2, plan.adjustments.count
|
|
end
|
|
|
|
test "generate_retirement! is idempotent" do
|
|
family = families(:empty)
|
|
Demo::Generator.new.send(:generate_retirement!, family)
|
|
assert_no_difference -> { family.goals.where(type: "Goal::Retirement").count } do
|
|
Demo::Generator.new.send(:generate_retirement!, family)
|
|
end
|
|
end
|
|
end
|