Merge pull request #4698 from consul/attachments_cache
Expire cache when adding documents and images
This commit is contained in:
@@ -7,7 +7,7 @@ class Document < ApplicationRecord
|
|||||||
hash_secret: Rails.application.secrets.secret_key_base
|
hash_secret: Rails.application.secrets.secret_key_base
|
||||||
|
|
||||||
belongs_to :user
|
belongs_to :user
|
||||||
belongs_to :documentable, polymorphic: true
|
belongs_to :documentable, polymorphic: true, touch: true
|
||||||
|
|
||||||
validates :title, presence: true
|
validates :title, presence: true
|
||||||
validates :user_id, presence: true
|
validates :user_id, presence: true
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ class Image < ApplicationRecord
|
|||||||
hash_secret: Rails.application.secrets.secret_key_base
|
hash_secret: Rails.application.secrets.secret_key_base
|
||||||
|
|
||||||
belongs_to :user
|
belongs_to :user
|
||||||
belongs_to :imageable, polymorphic: true
|
belongs_to :imageable, polymorphic: true, touch: true
|
||||||
|
|
||||||
validates :title, presence: true
|
validates :title, presence: true
|
||||||
validate :validate_title_length
|
validate :validate_title_length
|
||||||
|
|||||||
@@ -9,7 +9,6 @@
|
|||||||
|
|
||||||
<% cache [locale_and_user_status(investment),
|
<% cache [locale_and_user_status(investment),
|
||||||
investment,
|
investment,
|
||||||
investment.image,
|
|
||||||
investment.author,
|
investment.author,
|
||||||
Flag.flagged?(current_user, investment),
|
Flag.flagged?(current_user, investment),
|
||||||
investment.followed_by?(current_user),
|
investment.followed_by?(current_user),
|
||||||
|
|||||||
@@ -400,6 +400,14 @@ describe Proposal do
|
|||||||
expect { proposal.update(tag_list: "new tag") }.to change { proposal.cache_version }
|
expect { proposal.update(tag_list: "new tag") }.to change { proposal.cache_version }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "expires cache when it has a new image" do
|
||||||
|
expect { create(:image, imageable: proposal) }.to change { proposal.cache_version }
|
||||||
|
end
|
||||||
|
|
||||||
|
it "expires cache when it has a new document" do
|
||||||
|
expect { create(:document, documentable: proposal) }.to change { proposal.cache_version }
|
||||||
|
end
|
||||||
|
|
||||||
it "expires cache when hidden" do
|
it "expires cache when hidden" do
|
||||||
expect { proposal.hide }.to change { proposal.cache_version }
|
expect { proposal.hide }.to change { proposal.cache_version }
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user