1
0
Fork 0
mirror of https://github.com/maybe-finance/maybe.git synced 2025-07-19 13:19:39 +02:00
Maybe/test/controllers/account/valuations_controller_test.rb
Zach Gollwitzer c3248cd796
Some checks failed
Publish Docker image / ci (push) Has been cancelled
Publish Docker image / Build docker image (push) Has been cancelled
Improve account transaction, trade, and valuation editing and sync experience (#1506)
* 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
2024-11-27 16:01:50 -05:00

61 lines
1.6 KiB
Ruby

require "test_helper"
class Account::ValuationsControllerTest < ActionDispatch::IntegrationTest
include EntryableResourceInterfaceTest
setup do
sign_in @user = users(:family_admin)
@entry = account_entries(:valuation)
end
test "error when valuation already exists for date" do
assert_no_difference [ "Account::Entry.count", "Account::Valuation.count" ] do
post account_valuations_url(@entry.account), params: {
account_entry: {
amount: 19800,
date: @entry.date,
currency: "USD"
}
}
end
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