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.
45 lines
1.5 KiB
Ruby
45 lines
1.5 KiB
Ruby
require "test_helper"
|
|
|
|
class Retirement::StatementsControllerTest < 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)
|
|
@source = pension_sources(:de_grv_bob)
|
|
end
|
|
|
|
test "404 when family retirement disabled" do
|
|
@user.family.update!(retirement_disabled: true)
|
|
get new_retirement_statement_url
|
|
assert_response :not_found
|
|
end
|
|
|
|
test "new renders the form" do
|
|
get new_retirement_statement_url
|
|
assert_response :success
|
|
end
|
|
|
|
test "create logs a statement" do
|
|
assert_difference -> { @plan.statements.count }, 1 do
|
|
post retirement_statements_url, params: { goal_retirement_statement: {
|
|
pension_source_id: @source.id, received_on: "2026-01-15",
|
|
projected_monthly_amount: 1600, projected_currency: "EUR",
|
|
projected_at_age: 67, current_points: 10.2, raw_source_doc: "Renteninformation 2026"
|
|
} }
|
|
end
|
|
assert_redirected_to retirement_path
|
|
end
|
|
|
|
test "destroy soft-deletes (keeps the audit row)" do
|
|
statement = goal_retirement_statements(:grv_2025)
|
|
assert_no_difference -> { Goal::RetirementStatement.unscoped.count } do
|
|
delete retirement_statement_url(statement)
|
|
end
|
|
assert statement.reload.deleted
|
|
assert_redirected_to retirement_path
|
|
end
|
|
end
|