1
0
Fork 0
mirror of https://github.com/maybe-finance/maybe.git synced 2025-07-29 10:09:39 +02:00

Remove manual merchant management (rules will replace)

This commit is contained in:
Zach Gollwitzer 2025-04-02 17:48:34 -04:00
parent f07940bf45
commit 83dcbd9ff0
44 changed files with 123 additions and 386 deletions

View file

@ -8,14 +8,13 @@ class Rule::ActionTest < ActiveSupport::TestCase
@transaction_rule = @family.rules.create!(resource_type: "transaction")
@account = @family.accounts.create!(name: "Rule test", balance: 1000, currency: "USD", accountable: Depository.new)
@grocery_category = @family.categories.create!(name: "Grocery")
@whole_foods_merchant = @family.merchants.create!(name: "Whole Foods")
@shopping_category = @family.categories.create!(name: "Shopping")
# Some sample transactions to work with
create_transaction(date: Date.current, account: @account, amount: 100, name: "Rule test transaction1", merchant: @whole_foods_merchant)
create_transaction(date: Date.current, account: @account, amount: 100, name: "Rule test transaction1", merchant: merchants(:amazon))
create_transaction(date: Date.current, account: @account, amount: -200, name: "Rule test transaction2")
create_transaction(date: 1.day.ago.to_date, account: @account, amount: 50, name: "Rule test transaction3")
create_transaction(date: 1.year.ago.to_date, account: @account, amount: 10, name: "Rule test transaction4", merchant: @whole_foods_merchant)
create_transaction(date: 1.year.ago.to_date, account: @account, amount: 10, name: "Rule test transaction4", merchant: merchants(:amazon))
create_transaction(date: 1.year.ago.to_date, account: @account, amount: 1000, name: "Rule test transaction5")
@rule_scope = @account.transactions
@ -25,13 +24,13 @@ class Rule::ActionTest < ActiveSupport::TestCase
action = Rule::Action.new(
rule: @transaction_rule,
action_type: "set_transaction_category",
value: @grocery_category.id
value: @shopping_category.id
)
action.apply(@rule_scope)
@rule_scope.reload.each do |transaction|
assert_equal @grocery_category.id, transaction.category_id
assert_equal @shopping_category.id, transaction.category_id
end
end
end