1
0
Fork 0
mirror of https://github.com/maybe-finance/maybe.git synced 2025-07-30 02:29:39 +02:00

Add backend for property account details

This commit is contained in:
Zach Gollwitzer 2024-08-22 14:54:14 -04:00
parent 4433488562
commit 5ea2fd5a23
17 changed files with 258 additions and 2 deletions

View file

@ -0,0 +1,71 @@
require "test_helper"
class PropertiesControllerTest < ActionDispatch::IntegrationTest
setup do
sign_in @user = users(:family_admin)
@account = accounts(:property)
end
test "creates property" do
assert_difference [ "Account.count", "Property.count" ] do
post properties_path, params: {
account: {
name: "Property",
balance: 500000,
currency: "USD",
accountable_type: "Property",
accountable_attributes: {
year_built: 2002,
area_value: 1000,
area_unit: "sqft",
address_attributes: {
line1: "123 Main St",
line2: "Apt 1",
locality: "Los Angeles",
region: "CA", # ISO3166-2 code
country: "US", # ISO3166-1 Alpha-2 code
postal_code: "90001"
}
}
}
}
end
created_account = Account.order(:created_at).last
assert_redirected_to account_path(created_account)
assert_equal "Property created successfully", flash[:notice]
assert_enqueued_with(job: AccountSyncJob)
end
test "updates property" do
assert_no_difference [ "Account.count", "Property.count" ] do
patch property_path(@account), params: {
account: {
name: "Updated Property",
balance: 500000,
currency: "USD",
accountable_type: "Property",
accountable_attributes: {
id: @account.accountable_id,
year_built: 2002,
area_value: 1000,
area_unit: "sqft",
address_attributes: {
line1: "123 Main St",
line2: "Apt 1",
locality: "Los Angeles",
region: "CA", # ISO3166-2 code
country: "US", # ISO3166-1 Alpha-2 code
postal_code: "90001"
}
}
}
}
end
assert_redirected_to account_path(@account)
assert_equal "Property updated successfully", flash[:notice]
assert_enqueued_with(job: AccountSyncJob)
end
end