mirror of
https://github.com/maybe-finance/maybe.git
synced 2025-08-02 20:15:22 +02:00
Add assign merchant rule for transactions (#2174)
This commit is contained in:
parent
0946a1497a
commit
cf72f1a387
3 changed files with 53 additions and 1 deletions
|
@ -58,4 +58,25 @@ class Rule::ActionTest < ActiveSupport::TestCase
|
|||
assert_equal [ tag ], transaction.reload.tags
|
||||
end
|
||||
end
|
||||
|
||||
test "set_transaction_merchant" do
|
||||
merchant = @family.merchants.create!(name: "Rule test merchant")
|
||||
|
||||
# Does not modify transactions that are locked (user edited them)
|
||||
@txn1.lock!(:merchant_id)
|
||||
|
||||
action = Rule::Action.new(
|
||||
rule: @transaction_rule,
|
||||
action_type: "set_transaction_merchant",
|
||||
value: merchant.id
|
||||
)
|
||||
|
||||
action.apply(@rule_scope)
|
||||
|
||||
assert_not_equal merchant.id, @txn1.reload.merchant_id
|
||||
|
||||
[ @txn2, @txn3 ].each do |transaction|
|
||||
assert_equal merchant.id, transaction.reload.merchant_id
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue