mirror of
https://github.com/we-promise/sure.git
synced 2026-04-19 03:54:08 +00:00
feat: Add duplicate button when a transaction is selected (#1123)
* feat: Add duplicate button when a transaction is selected * feat: add merchant field * feat: add duplicate transaction btn 2
This commit is contained in:
@@ -309,6 +309,38 @@ end
|
||||
assert_not entry.protected_from_sync?
|
||||
end
|
||||
|
||||
test "new with duplicate_entry_id pre-fills form from source transaction" do
|
||||
@entry.reload
|
||||
|
||||
get new_transaction_url(duplicate_entry_id: @entry.id)
|
||||
assert_response :success
|
||||
assert_select "input[name='entry[name]'][value=?]", @entry.name
|
||||
assert_select "input[type='number'][name='entry[amount]']" do |elements|
|
||||
assert_equal sprintf("%.2f", @entry.amount.abs), elements.first["value"]
|
||||
end
|
||||
assert_select "input[type='hidden'][name='entry[entryable_attributes][merchant_id]']"
|
||||
end
|
||||
|
||||
test "new with invalid duplicate_entry_id renders empty form" do
|
||||
get new_transaction_url(duplicate_entry_id: -1)
|
||||
assert_response :success
|
||||
assert_select "input[name='entry[name]']" do |elements|
|
||||
assert_nil elements.first["value"]
|
||||
end
|
||||
end
|
||||
|
||||
test "new with duplicate_entry_id from another family does not prefill form" do
|
||||
other_family = families(:empty)
|
||||
other_account = other_family.accounts.create!(name: "Other", balance: 0, currency: "USD", accountable: Depository.new)
|
||||
other_entry = create_transaction(account: other_account, name: "Should not leak", amount: 50)
|
||||
|
||||
get new_transaction_url(duplicate_entry_id: other_entry.id)
|
||||
assert_response :success
|
||||
assert_select "input[name='entry[name]']" do |elements|
|
||||
assert_nil elements.first["value"]
|
||||
end
|
||||
end
|
||||
|
||||
test "unlock clears import_locked flag" do
|
||||
family = families(:empty)
|
||||
sign_in users(:empty)
|
||||
|
||||
Reference in New Issue
Block a user