Normalize whitespace in text rule matching (#890)

Normalize whitespace in text-based rule filters so

transaction names with irregular spacing still match.

Refs #886
This commit is contained in:
Juan José Mata
2026-02-06 00:00:04 +01:00
committed by GitHub
parent d09765a14c
commit 4938c44a68
2 changed files with 40 additions and 2 deletions

View File

@@ -94,6 +94,30 @@ class RuleTest < ActiveSupport::TestCase
assert_not transaction_entry.excluded, "Transaction should not be excluded when attribute is locked"
end
test "transaction name rules normalize whitespace in comparisons" do
transaction_entry = create_transaction(
date: Date.current,
account: @account,
name: "Company - Mobile",
amount: 80
)
rule = Rule.create!(
family: @family,
resource_type: "transaction",
effective_date: 1.day.ago.to_date,
conditions: [ Rule::Condition.new(condition_type: "transaction_name", operator: "like", value: "Company - Mobile") ],
actions: [ Rule::Action.new(action_type: "set_transaction_category", value: @groceries_category.id) ]
)
assert_equal 1, rule.affected_resource_count
rule.apply
transaction_entry.reload
assert_equal @groceries_category, transaction_entry.transaction.category
end
# Artificial limitation put in place to prevent users from creating overly complex rules
# Rules should be shallow and wide
test "no nested compound conditions" do