Commit d2e306feb50c08fb00deb1b8e9c216dcb5be0ea2
1 parent
f323c51d
Exists in
master
and in
27 other branches
people_block: fix cache expiration of members_block
fixes #11
Showing
3 changed files
with
11 additions
and
5 deletions
Show diff stats
app/models/block.rb
... | ... | @@ -192,7 +192,7 @@ class Block < ActiveRecord::Base |
192 | 192 | |
193 | 193 | # Override in your subclasses. |
194 | 194 | # Define which events and context should cause the block cache to expire |
195 | - # Possible events are: :article, :profile, :friendship, :category | |
195 | + # Possible events are: :article, :profile, :friendship, :category, :role_assignment | |
196 | 196 | # Possible contexts are: :profile, :environment |
197 | 197 | def self.expire_on |
198 | 198 | { | ... | ... |
app/sweepers/role_assignment_sweeper.rb
... | ... | @@ -14,19 +14,21 @@ protected |
14 | 14 | |
15 | 15 | def expire_caches(role_assignment) |
16 | 16 | expire_cache(role_assignment.accessor) |
17 | - expire_cache(role_assignment.resource) if role_assignment.resource.respond_to?(:cache_keys) | |
17 | + expire_cache(role_assignment.resource) if role_assignment.resource.kind_of?(Profile) | |
18 | 18 | end |
19 | 19 | |
20 | 20 | def expire_cache(profile) |
21 | 21 | per_page = Noosfero::Constants::PROFILE_PER_PAGE |
22 | - profile.cache_keys(:per_page => per_page).each { |ck| | |
23 | - expire_timeout_fragment(ck) | |
24 | - } | |
22 | + | |
23 | + profile.cache_keys(:per_page => per_page).each { |ck| expire_timeout_fragment(ck) } | |
24 | + expire_timeout_fragment(profile.members_cache_key(:per_page => per_page)) | |
25 | 25 | |
26 | 26 | profile.blocks_to_expire_cache.each { |block| |
27 | 27 | blocks = profile.blocks.select{|b| b.kind_of?(block)} |
28 | 28 | BlockSweeper.expire_blocks(blocks) |
29 | 29 | } |
30 | + | |
31 | + expire_blocks_cache(profile, [:role_assignment]) | |
30 | 32 | end |
31 | 33 | |
32 | 34 | end | ... | ... |