Files
sure/test/models/demo/generator_test.rb
Guillem Arias 53b2a05749 feat(retirement): PR4f demo seed
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.
2026-05-29 12:43:19 +02:00

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