Testing Tag Replacement Operations in maybe-finance/maybe
Unit test suite for tag management functionality in the Maybe Finance application, focusing on tag replacement and deletion operations. The tests validate the proper handling of tag associations with transactions during replacement scenarios.
Test Coverage Overview
Implementation Analysis
Technical Details
Best Practices Demonstrated
maybe-finance/maybe
test/models/tag_test.rb
require "test_helper"
class TagTest < ActiveSupport::TestCase
test "replace and destroy" do
old_tag = tags(:one)
new_tag = tags(:two)
assert_difference "Tag.count", -1 do
old_tag.replace_and_destroy!(new_tag)
end
old_tag.transactions.each do |txn|
txn.reload
assert_includes txn.tags, new_tag
assert_not_includes txn.tags, old_tag
end
end
end