mirror of
https://github.com/we-promise/sure.git
synced 2026-05-30 07:49:01 +00:00
Functional data-entry surface on the (still preview) /retirement page. The polished combined-page UI is PR4; this ships plain forms + lists so a preview user can populate a plan end to end. - RetirementScoped concern: tier-1 preview gate + tier-2 family killswitch + per-owner plan bootstrap (Goal::Retirement.for_owner find-or-creates, so children always have a parent). RetirementController now uses it. - Nested controllers under Retirement::: PensionSources (full CRUD), Statements (new/create + soft-delete destroy — append-only audit), Adjustments (full CRUD), Buckets (replace-all account selection, same-family filtered). All scoped to the current user's own plan, so cross-user access is impossible by construction. - Routes nested under `resource :retirement` via `scope module:`. - Views: show page rewritten into management sections (sources, adjustments, bucket checkboxes, statement journal) + plain styled_form_with forms. Money carries privacy-sensitive. - Goal gains a target_amount_required? hook (true); Goal::Retirement overrides it false — the forecast owns the target (PR3), so a plan can exist before any target is set. - EN locale for the new surface. 111 controller+model tests green. Note: delete uses Turbo confirm for now; PR4 swaps in the skinned DS::Dialog per the design.
52 lines
1.7 KiB
Ruby
52 lines
1.7 KiB
Ruby
require "test_helper"
|
|
|
|
class Retirement::AdjustmentsControllerTest < ActionDispatch::IntegrationTest
|
|
setup do
|
|
@user = users(:family_admin)
|
|
@user.update!(preferences: (@user.preferences || {}).merge("preview_features_enabled" => true))
|
|
@user.family.update!(retirement_disabled: false)
|
|
sign_in @user
|
|
ensure_tailwind_build
|
|
@plan = Goal::Retirement.for_owner(@user)
|
|
end
|
|
|
|
test "404 when family retirement disabled" do
|
|
@user.family.update!(retirement_disabled: true)
|
|
get new_retirement_adjustment_url
|
|
assert_response :not_found
|
|
end
|
|
|
|
test "new renders the form" do
|
|
get new_retirement_adjustment_url
|
|
assert_response :success
|
|
end
|
|
|
|
test "edit renders the form" do
|
|
get edit_retirement_adjustment_url(goal_retirement_adjustments(:mortgage_paid_off))
|
|
assert_response :success
|
|
end
|
|
|
|
test "create adds an adjustment" do
|
|
assert_difference -> { @plan.adjustments.count }, 1 do
|
|
post retirement_adjustments_url, params: { goal_retirement_adjustment: {
|
|
label: "Healthcare", amount_today: 220, currency: "USD", from_age: 65, ordinal: 5
|
|
} }
|
|
end
|
|
assert_redirected_to retirement_path
|
|
end
|
|
|
|
test "update edits an adjustment" do
|
|
adjustment = goal_retirement_adjustments(:mortgage_paid_off)
|
|
patch retirement_adjustment_url(adjustment), params: { goal_retirement_adjustment: { label: "Renamed" } }
|
|
assert_redirected_to retirement_path
|
|
assert_equal "Renamed", adjustment.reload.label
|
|
end
|
|
|
|
test "destroy removes an adjustment" do
|
|
adjustment = @plan.adjustments.create!(label: "Temp", amount_today: -1, currency: "USD", from_age: 60, ordinal: 9)
|
|
assert_difference -> { @plan.adjustments.count }, -1 do
|
|
delete retirement_adjustment_url(adjustment)
|
|
end
|
|
end
|
|
end
|