Skip to content

armgit / sure

Public Imported from GitHub
0

The personal finance app for everyone (by everyone)

Ruby

FIX merchant regression (#659)

soky srmd1b8d585cee5
diff --git a/app/models/family.rb b/app/models/family.rb
index 0735749749..8e48ced1c7 100644
--- a/app/models/family.rb
+++ b/app/models/family.rb
@@ -51,7 +51,8 @@ class Family < ApplicationRecord
.where(family: self)
.recently_unlinked
.pluck(:merchant_id)
- Merchant.where(id: (assigned_ids + recently_unlinked_ids).uniq)
+ family_merchant_ids = merchants.pluck(:id)
+ Merchant.where(id: (assigned_ids + recently_unlinked_ids + family_merchant_ids).uniq)
end
def auto_categorize_transactions_later(transactions, rule_run_id: nil)
diff --git a/test/models/family_test.rb b/test/models/family_test.rb
index 0229aa6e1a..cf5b800a87 100644
--- a/test/models/family_test.rb
+++ b/test/models/family_test.rb
@@ -6,4 +6,12 @@ class FamilyTest < ActiveSupport::TestCase
def setup
@syncable = families(:dylan_family)
end
+
+ test "available_merchants includes family merchants without transactions" do
+ family = families(:dylan_family)
+
+ new_merchant = family.merchants.create!(name: "New Test Merchant")
+
+ assert_includes family.available_merchants, new_merchant
+ end
end