Fix duplicate category creation on import (#791)

* Repro

* Fix

* Update signage
This commit is contained in:
Zach Gollwitzer
2024-05-22 10:02:03 -04:00
committed by GitHub
parent 77f166a5f8
commit 41c991384a
4 changed files with 24 additions and 12 deletions

View File

@@ -39,7 +39,10 @@ class ImportTest < ActiveSupport::TestCase
end
test "publishes a valid import" do
assert_difference -> { Transaction::Category.count } => 2, -> { Transaction.count } => 2 do
# Import has 3 unique categories: "Food & Drink", "Income", and "Shopping" (x2)
# Fixtures already define "Food & Drink" and "Income", so these should not be created
# "Shopping" is a new category, but should only be created 1x during import
assert_difference -> { Transaction.count } => 4, -> { Transaction::Category.count } => 1 do
@loaded_import.publish
end