mirror of
https://github.com/we-promise/sure.git
synced 2026-05-10 14:15:01 +00:00
* fix: enable and persist notes on split child transactions (#1535) * fix: enable tags on split child transactions and new tests for split child notes + tags * Update app/components/DS/dialog_controller.js Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Signed-off-by: Xing Hong <39619359+xingxing21@users.noreply.github.com> * fix(transactions): only stream notes frame when notes params are submitted * fix(transactions): address PR review issues in notes stream and tests --------- Signed-off-by: Xing Hong <39619359+xingxing21@users.noreply.github.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
@@ -20,7 +20,7 @@ class TransactionsControllerTest < ActionDispatch::IntegrationTest
|
||||
nature: "inflow",
|
||||
entryable_type: @entry.entryable_type,
|
||||
entryable_attributes: {
|
||||
tag_ids: [ Tag.first.id, Tag.second.id ],
|
||||
tag_ids: [ tags(:one).id, tags(:two).id ],
|
||||
category_id: Category.first.id,
|
||||
merchant_id: Merchant.first.id
|
||||
}
|
||||
@@ -49,7 +49,7 @@ class TransactionsControllerTest < ActionDispatch::IntegrationTest
|
||||
excluded: false,
|
||||
entryable_attributes: {
|
||||
id: @entry.entryable_id,
|
||||
tag_ids: [ Tag.first.id, Tag.second.id ],
|
||||
tag_ids: [ tags(:one).id, tags(:two).id ],
|
||||
category_id: Category.first.id,
|
||||
merchant_id: Merchant.first.id
|
||||
}
|
||||
@@ -63,7 +63,7 @@ class TransactionsControllerTest < ActionDispatch::IntegrationTest
|
||||
assert_equal Date.current, @entry.date
|
||||
assert_equal "USD", @entry.currency
|
||||
assert_equal -100, @entry.amount
|
||||
assert_equal [ Tag.first.id, Tag.second.id ], @entry.entryable.tag_ids.sort
|
||||
assert_equal [ tags(:one).id, tags(:two).id ].sort, @entry.entryable.tag_ids.sort
|
||||
assert_equal Category.first.id, @entry.entryable.category_id
|
||||
assert_equal Merchant.first.id, @entry.entryable.merchant_id
|
||||
assert_equal "test notes", @entry.notes
|
||||
@@ -96,6 +96,33 @@ class TransactionsControllerTest < ActionDispatch::IntegrationTest
|
||||
assert_dom "#total-transactions", count: 1, text: "1"
|
||||
end
|
||||
|
||||
test "can update notes on split child transaction" do
|
||||
parent = create_transaction(account: accounts(:depository), amount: 100)
|
||||
parent.split!([ { name: "Part 1", amount: 60, category_id: nil }, { name: "Part 2", amount: 40, category_id: nil } ])
|
||||
child = parent.child_entries.first
|
||||
|
||||
patch transaction_url(child), params: {
|
||||
entry: { notes: "split child note", entryable_attributes: { id: child.entryable_id } }
|
||||
}
|
||||
|
||||
assert_response :redirect
|
||||
assert_equal "split child note", child.reload.notes
|
||||
end
|
||||
|
||||
test "can update tags on split child transaction" do
|
||||
parent = create_transaction(account: accounts(:depository), amount: 100)
|
||||
parent.split!([ { name: "Part 1", amount: 60, category_id: nil }, { name: "Part 2", amount: 40, category_id: nil } ])
|
||||
child = parent.child_entries.first
|
||||
tag = tags(:one)
|
||||
|
||||
patch transaction_url(child), params: {
|
||||
entry: { entryable_attributes: { id: child.entryable_id, tag_ids: [ tag.id ] } }
|
||||
}
|
||||
|
||||
assert_response :redirect
|
||||
assert_equal [ tag.id ], child.reload.entryable.tag_ids
|
||||
end
|
||||
|
||||
test "split parent rows mark amount as privacy-sensitive" do
|
||||
entry = create_transaction(account: accounts(:depository), amount: 100, name: "Split parent")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user