From c3e49384d093b7a1fd5aef261b02395c5680ec8b Mon Sep 17 00:00:00 2001 From: Daniela Soares Feitosa Date: Thu, 21 Nov 2013 12:06:37 +0000 Subject: [PATCH] Removed whitespaces --- app/helpers/sweeper_helper.rb | 10 +++++----- app/models/article_block.rb | 4 ++-- app/models/block.rb | 4 ++-- app/sweepers/article_sweeper.rb | 6 +++--- app/sweepers/category_sweeper.rb | 4 +++- plugins/display_content/lib/display_content_block.rb | 2 +- test/unit/block_test.rb | 2 +- 7 files changed, 17 insertions(+), 15 deletions(-) diff --git a/app/helpers/sweeper_helper.rb b/app/helpers/sweeper_helper.rb index fac400a..01db9bd 100644 --- a/app/helpers/sweeper_helper.rb +++ b/app/helpers/sweeper_helper.rb @@ -44,7 +44,7 @@ module SweeperHelper def expire_profile_index(profile) expire_timeout_fragment(profile.relationships_cache_key) end - + def expire_blocks_cache(context, causes) if context.kind_of?(Profile) profile = context @@ -53,7 +53,7 @@ module SweeperHelper environment = context profile = nil end - + blocks_to_expire = [] if profile profile.blocks.each {|block| @@ -65,9 +65,9 @@ module SweeperHelper conditions = block.class.expire_on blocks_to_expire << block unless (conditions[:environment] & causes).empty? } - + blocks_to_expire.uniq! BlockSweeper.expire_blocks(blocks_to_expire) - end - + end + end diff --git a/app/models/article_block.rb b/app/models/article_block.rb index c878f0d..aaf7bae 100644 --- a/app/models/article_block.rb +++ b/app/models/article_block.rb @@ -23,7 +23,7 @@ class ArticleBlock < Block def article_id self.settings[:article_id] end - + def article_id= value self.settings[:article_id] = value.blank? ? nil : value.to_i end @@ -63,7 +63,7 @@ class ArticleBlock < Block end settings_items :visualization_format, :type => :string, :default => 'short' - + def self.expire_on { :profile => [:article], :environment => [:article] } end diff --git a/app/models/block.rb b/app/models/block.rb index 819c11d..8807194 100644 --- a/app/models/block.rb +++ b/app/models/block.rb @@ -133,7 +133,7 @@ class Block < ActiveRecord::Base def cache_key(language='en') active_record_cache_key+'-'+language end - + def timeout 4.hours end @@ -145,7 +145,7 @@ class Block < ActiveRecord::Base # Override in your subclasses. # Define which events and context should cause the block cache to expire # Possible events are: :article, :profile, :friendship, :category - # Possible contexts are: :profile, :environment + # Possible contexts are: :profile, :environment def self.expire_on { :profile => [], diff --git a/app/sweepers/article_sweeper.rb b/app/sweepers/article_sweeper.rb index 924ba7b..942a893 100644 --- a/app/sweepers/article_sweeper.rb +++ b/app/sweepers/article_sweeper.rb @@ -15,15 +15,15 @@ class ArticleSweeper < ActiveRecord::Observer Article.find(article.parent_id_was).touch if article.parent_id_was end end - - + + protected def expire_caches(article) expire_blocks_cache(article.profile, [:article]) return if !article.environment - + article.hierarchy(true).each { |a| a.touch if a != article } env = article.profile.environment if env && (env.portal_community == article.profile) diff --git a/app/sweepers/category_sweeper.rb b/app/sweepers/category_sweeper.rb index 8c06b8a..5876cf4 100644 --- a/app/sweepers/category_sweeper.rb +++ b/app/sweepers/category_sweeper.rb @@ -3,8 +3,10 @@ class CategorySweeper < ActiveRecord::Observer include SweeperHelper def after_save(category) - # expire_fragment(category.environment.id.to_s + "_categories_menu") expire_blocks_cache(category.environment, [:category]) + + # Needed for environments with application layout + expire_fragment(category.environment.id.to_s + "_categories_menu") end def after_destroy(category) diff --git a/plugins/display_content/lib/display_content_block.rb b/plugins/display_content/lib/display_content_block.rb index 0983c69..dadada6 100644 --- a/plugins/display_content/lib/display_content_block.rb +++ b/plugins/display_content/lib/display_content_block.rb @@ -86,5 +86,5 @@ class DisplayContentBlock < Block def self.expire_on { :profile => [:article], :environment => [:article] } end - + end diff --git a/test/unit/block_test.rb b/test/unit/block_test.rb index 24a2b3f..12f029d 100644 --- a/test/unit/block_test.rb +++ b/test/unit/block_test.rb @@ -160,7 +160,7 @@ class BlockTest < ActiveSupport::TestCase conditions = Block.expire_on assert conditions[:profile].kind_of?(Array) end - + should 'inform conditions for expiration on environment context' do conditions = Block.expire_on assert conditions[:environment].kind_of?(Array) -- libgit2 0.21.2