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:
+1
-1
@@ -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
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user