mirror of
https://github.com/maybe-finance/maybe.git
synced 2025-08-04 21:15:19 +02:00
Fix attribute locking namespace conflict, duplicate syncs
This commit is contained in:
parent
ab5bce3462
commit
137219c121
11 changed files with 87 additions and 28 deletions
|
@ -21,7 +21,7 @@ class Rule::ActionTest < ActiveSupport::TestCase
|
|||
|
||||
test "set_transaction_category" do
|
||||
# Does not modify transactions that are locked (user edited them)
|
||||
@txn1.lock!(:category_id)
|
||||
@txn1.lock_attr!(:category_id)
|
||||
|
||||
action = Rule::Action.new(
|
||||
rule: @transaction_rule,
|
||||
|
@ -42,7 +42,7 @@ class Rule::ActionTest < ActiveSupport::TestCase
|
|||
tag = @family.tags.create!(name: "Rule test tag")
|
||||
|
||||
# Does not modify transactions that are locked (user edited them)
|
||||
@txn1.lock!(:tag_ids)
|
||||
@txn1.lock_attr!(:tag_ids)
|
||||
|
||||
action = Rule::Action.new(
|
||||
rule: @transaction_rule,
|
||||
|
@ -63,7 +63,7 @@ class Rule::ActionTest < ActiveSupport::TestCase
|
|||
merchant = @family.merchants.create!(name: "Rule test merchant")
|
||||
|
||||
# Does not modify transactions that are locked (user edited them)
|
||||
@txn1.lock!(:merchant_id)
|
||||
@txn1.lock_attr!(:merchant_id)
|
||||
|
||||
action = Rule::Action.new(
|
||||
rule: @transaction_rule,
|
||||
|
@ -84,7 +84,7 @@ class Rule::ActionTest < ActiveSupport::TestCase
|
|||
new_name = "Renamed Transaction"
|
||||
|
||||
# Does not modify transactions that are locked (user edited them)
|
||||
@txn1.lock!(:name)
|
||||
@txn1.lock_attr!(:name)
|
||||
|
||||
action = Rule::Action.new(
|
||||
rule: @transaction_rule,
|
||||
|
|
|
@ -188,4 +188,24 @@ class SyncTest < ActiveSupport::TestCase
|
|||
assert_equal "stale", stale_pending.reload.status
|
||||
assert_equal "stale", stale_syncing.reload.status
|
||||
end
|
||||
|
||||
test "expand_window_if_needed widens start and end dates on a pending sync" do
|
||||
initial_start = 1.day.ago.to_date
|
||||
initial_end = 1.day.ago.to_date
|
||||
|
||||
sync = Sync.create!(
|
||||
syncable: accounts(:depository),
|
||||
window_start_date: initial_start,
|
||||
window_end_date: initial_end
|
||||
)
|
||||
|
||||
new_start = 5.days.ago.to_date
|
||||
new_end = Date.current
|
||||
|
||||
sync.expand_window_if_needed(new_start, new_end)
|
||||
sync.reload
|
||||
|
||||
assert_equal new_start, sync.window_start_date
|
||||
assert_equal new_end, sync.window_end_date
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue