Commit d0b4277a67be9b4c1503105702a300322ae61d2a
1 parent
95b2c3fc
Exists in
master
and in
22 other branches
Fixing block and article delegate
Showing
6 changed files
with
6 additions
and
4 deletions
Show diff stats
app/models/article.rb
... | ... | @@ -665,7 +665,7 @@ class Article < ActiveRecord::Base |
665 | 665 | self.categories.collect(&:name) |
666 | 666 | end |
667 | 667 | |
668 | - delegate :region, :region_id, :environment, :environment_id, :to => :profile | |
668 | + delegate :region, :region_id, :environment, :environment_id, :to => :profile, :allow_nil => true | |
669 | 669 | def name_sortable # give a different name for solr |
670 | 670 | name |
671 | 671 | end | ... | ... |
app/models/block.rb
app/models/box.rb
... | ... | @@ -4,6 +4,6 @@ class Box < ActiveRecord::Base |
4 | 4 | has_many :blocks, :dependent => :destroy, :order => 'position' |
5 | 5 | |
6 | 6 | def environment |
7 | - owner.kind_of?(Environment) ? owner : owner.environment | |
7 | + owner ? (owner.kind_of?(Environment) ? owner : owner.environment) : nil | |
8 | 8 | end |
9 | 9 | end | ... | ... |
app/sweepers/article_sweeper.rb
... | ... | @@ -13,6 +13,7 @@ class ArticleSweeper < ActiveRecord::Observer |
13 | 13 | protected |
14 | 14 | |
15 | 15 | def expire_caches(article) |
16 | + return if !article.environment | |
16 | 17 | article.hierarchy.each { |a| a.touch if a != article } |
17 | 18 | blocks = article.profile.blocks |
18 | 19 | blocks += article.profile.environment.blocks if article.profile.environment | ... | ... |
app/sweepers/block_sweeper.rb
test/unit/article_test.rb
... | ... | @@ -1210,7 +1210,7 @@ class ArticleTest < ActiveSupport::TestCase |
1210 | 1210 | assert_nothing_raised { a.language = 'en' } |
1211 | 1211 | end |
1212 | 1212 | |
1213 | - should 'validade inclusion of language' do | |
1213 | + should 'validate inclusion of language' do | |
1214 | 1214 | a = build(Article, :profile_id => fast_create(Profile).id) |
1215 | 1215 | a.language = '12' |
1216 | 1216 | a.valid? | ... | ... |