mirror of
https://github.com/we-promise/sure.git
synced 2026-04-19 20:14:08 +00:00
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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user