Fix property subtype not persisting on edit (#930)

* Fix property subtype not persisting on edit

* Add regression test for property subtype persistence

This change introduces model specs and factories to cover
property subtype persistence on update.

FactoryBot setup and test dependencies were adjusted to
support the new specs.

* Add regression test for property subtype persistence

* remove unused FactoryBot factories and test

* remove FactoryBot in Gemfile.lock

* Fix no-op regression test for property subtype update

* Delete no-op property_test

* add pimary_residence in properties fixtures

* add capybara system test for property subtype persistence

* fix spelling and indent

* rename test to "can persist property subtype"

Signed-off-by: HugoleDino <135261771+HugoleDino@users.noreply.github.com>

---------

Signed-off-by: HugoleDino <135261771+HugoleDino@users.noreply.github.com>
This commit is contained in:
HugoleDino
2026-02-11 08:51:31 +01:00
committed by GitHub
parent 6bef5be089
commit 1ebbd5bbc5
3 changed files with 81 additions and 5 deletions

View File

@@ -6,13 +6,14 @@
placeholder: "Vacation home",
required: true %>
<%= form.select :subtype,
Property::SUBTYPES.map { |k, v| [v[:long], k] },
{ prompt: "Select type", label: "Property type" }, required: true %>
<%= form.hidden_field :accountable_type, value: "Property" %>
<%= form.fields_for :accountable do |property_form| %>
<%= property_form.select :subtype,
Property::SUBTYPES.map { |k, v| [v[:long], k] },
{ prompt: "Select type", label: "Property type" }, required: true %>
<div class="flex items-center gap-2">
<%= property_form.number_field :year_built,
label: "Year Built (optional)",

View File

@@ -1,4 +1,10 @@
one:
year_built: 2002
area_value: 1000
area_unit: "sqft"
area_unit: "sqft"
primary_residence:
id: c506b873-dd1b-4136-8564-02367303946a
subtype: Single Family Home
created_at: <%= Time.current %>
updated_at: <%= Time.current %>

View File

@@ -0,0 +1,69 @@
require "application_system_test_case"
class PropertiesEditTest < ApplicationSystemTestCase
setup do
sign_in @user = users(:family_admin)
Family.any_instance.stubs(:get_link_token).returns("test-link-token")
visit root_url
open_new_account_modal
create_new_property_account
end
test "can persist property subtype" do
click_link "[system test] Property Account"
find("[data-testid='account-menu']").click
click_on "Edit"
assert_selector "#account_accountable_attributes_subtype"
assert_selector(
"#account_accountable_attributes_subtype option[selected]",
text: "Single Family Home"
)
end
private
def open_new_account_modal
within "[data-controller='DS--tabs']" do
click_button "All"
click_link "New account"
end
end
def create_new_property_account
click_link "Property"
account_name = "[system test] Property Account"
fill_in "Name*", with: account_name
select "Single Family Home", from: "Property type*"
fill_in "Year Built (optional)", with: 2005
fill_in "Area (optional)", with: 2250
click_button "Next"
# Step 2: Enter balance information
assert_text "Value"
fill_in "account[balance]", with: 500000
click_button "Next"
# Step 3: Enter address information
assert_text "Address"
fill_in "Address Line 1", with: "123 Main St"
fill_in "City", with: "San Francisco"
fill_in "State/Region", with: "CA"
fill_in "Postal Code", with: "94101"
fill_in "Country", with: "US"
click_button "Save"
# Verify account was created and is now active
assert_text account_name
created_account = Account.order(:created_at).last
assert_equal "active", created_account.status
assert_equal 500000, created_account.balance
assert_equal "123 Main St", created_account.property.address.line1
assert_equal "San Francisco", created_account.property.address.locality
end
end