mirror of
https://github.com/we-promise/sure.git
synced 2026-07-12 04:45:19 +00:00
#2356 build the accountable inside Account#subtype= so a top-level subtype survives create. That fix assumes accountable_type is already set when subtype= runs, but the real controller path violates it: strong-params permit preserves filter order, and account_params lists :subtype before :accountable_type. So on create subtype= runs while accountable_type (and accountable_class) is still blank, the build is skipped, and the chosen subtype is silently dropped — the account renders with the type's fallback label (e.g. a Depository shows 'Cash' instead of 'Savings'). The existing regression test only covered the accountable_type-first order, so it never caught this. Make the writer order-independent: when subtype arrives before the type, stash it and apply it from an accountable_type= override once the type is known. Add regression tests for the permit order and for create_and_sync.