Touch Account when adding or removing a Tag

so we can properly cache the tags partial using account as part of the key.
This commit is contained in:
Mike Dalessio
2025-03-24 16:41:45 -04:00
parent 9c690c5822
commit 506f74144b
2 changed files with 12 additions and 4 deletions
+1 -1
View File
@@ -1,7 +1,7 @@
class Tag < ApplicationRecord
include Filterable
belongs_to :account, default: -> { Current.account }
belongs_to :account, default: -> { Current.account }, touch: true
has_many :taggings, dependent: :destroy
has_many :bubbles, through: :taggings
+11 -3
View File
@@ -1,7 +1,15 @@
require "test_helper"
class TagTest < ActiveSupport::TestCase
# test "the truth" do
# assert true
# end
test "creating or deleting a tag touches the account, so tags dialog fragment cache is invalidated" do
account = accounts("37s")
assert_changes -> { account.reload.updated_at } do
account.tags.create!(title: "ReleaseBlocker")
end
assert_changes -> { account.reload.updated_at } do
account.tags.find_by(title: "ReleaseBlocker").destroy
end
end
end