mirror of
https://github.com/maybe-finance/maybe.git
synced 2025-07-19 13:19:39 +02:00
Account:: namespace simplifications and cleanup (#2110)
* Flatten Holding model * Flatten balance model * Entries domain renames * Fix valuations reference * Fix trades stream * Fix brakeman warnings * Fix tests * Replace existing entryable type references in DB
This commit is contained in:
parent
f181ba941f
commit
e657c40d19
172 changed files with 1297 additions and 1258 deletions
62
test/controllers/valuations_controller_test.rb
Normal file
62
test/controllers/valuations_controller_test.rb
Normal file
|
@ -0,0 +1,62 @@
|
|||
require "test_helper"
|
||||
|
||||
class ValuationsControllerTest < ActionDispatch::IntegrationTest
|
||||
include EntryableResourceInterfaceTest
|
||||
|
||||
setup do
|
||||
sign_in @user = users(:family_admin)
|
||||
@entry = entries(:valuation)
|
||||
end
|
||||
|
||||
test "error when valuation already exists for date" do
|
||||
assert_no_difference [ "Entry.count", "Valuation.count" ] do
|
||||
post valuations_url(@entry.account), params: {
|
||||
entry: {
|
||||
account_id: @entry.account_id,
|
||||
amount: 19800,
|
||||
date: @entry.date,
|
||||
currency: "USD"
|
||||
}
|
||||
}
|
||||
end
|
||||
|
||||
assert_response :unprocessable_entity
|
||||
end
|
||||
|
||||
test "creates entry with basic attributes" do
|
||||
assert_difference [ "Entry.count", "Valuation.count" ], 1 do
|
||||
post valuations_url, params: {
|
||||
entry: {
|
||||
name: "New entry",
|
||||
amount: 10000,
|
||||
currency: "USD",
|
||||
date: Date.current,
|
||||
account_id: @entry.account_id
|
||||
}
|
||||
}
|
||||
end
|
||||
|
||||
created_entry = 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 [ "Entry.count", "Valuation.count" ] do
|
||||
patch valuation_url(@entry), params: {
|
||||
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
|
Loading…
Add table
Add a link
Reference in a new issue