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

Improve account transaction, trade, and valuation editing and sync experience (#1506)
Some checks failed
Publish Docker image / ci (push) Has been cancelled
Publish Docker image / Build docker image (push) Has been cancelled

* Consolidate entry controller logic

* Transaction builder

* Update trades controller to use new params

* Load account charts in turbo frames, fix PG overflow

* Consolidate tests

* Tests passing

* Remove unused code

* Add client side trade form validations
This commit is contained in:
Zach Gollwitzer 2024-11-27 16:01:50 -05:00 committed by GitHub
parent 76f2714006
commit c3248cd796
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
97 changed files with 1103 additions and 1159 deletions

View file

@ -1,36 +1,11 @@
require "test_helper"
class Account::ValuationsControllerTest < ActionDispatch::IntegrationTest
include EntryableResourceInterfaceTest
setup do
sign_in @user = users(:family_admin)
@entry = account_entries :valuation
end
test "should get index" do
get account_valuations_url(@entry.account)
assert_response :success
end
test "should get new" do
get new_account_valuation_url(@entry.account)
assert_response :success
end
test "create" do
assert_difference [ "Account::Entry.count", "Account::Valuation.count" ], 1 do
post account_valuations_url(@entry.account), params: {
account_entry: {
name: "Manual valuation",
amount: 19800,
date: Date.current,
currency: "USD"
}
}
end
assert_equal "Valuation created successfully.", flash[:notice]
assert_enqueued_with job: SyncJob
assert_redirected_to account_valuations_path(@entry.account)
@entry = account_entries(:valuation)
end
test "error when valuation already exists for date" do
@ -44,7 +19,43 @@ class Account::ValuationsControllerTest < ActionDispatch::IntegrationTest
}
end
assert_equal "Date has already been taken", flash[:alert]
assert_redirected_to @entry.account
assert_response :unprocessable_entity
end
test "creates entry with basic attributes" do
assert_difference [ "Account::Entry.count", "Account::Valuation.count" ], 1 do
post account_valuations_url, params: {
account_entry: {
name: "New entry",
amount: 10000,
currency: "USD",
date: Date.current,
account_id: @entry.account_id
}
}
end
created_entry = Account::Entry.order(created_at: :desc).first
assert_enqueued_with job: SyncJob
assert_redirected_to account_url(created_entry.account)
end
test "updates entry with basic attributes" do
assert_no_difference [ "Account::Entry.count", "Account::Valuation.count" ] do
patch account_valuation_url(@entry), params: {
account_entry: {
name: "Updated entry",
amount: 20000,
currency: "USD",
date: Date.current
}
}
end
assert_enqueued_with job: SyncJob
assert_redirected_to account_url(@entry.account)
end
end