Commit 04bbb571c04d7230aa04f5ce6415282662647dd3

Authored by Antonio Terceiro
2 parents 25bc7db6 9e88d499

Merge branch 'stable'

app/models/environment.rb
... ... @@ -597,7 +597,7 @@ class Environment < ActiveRecord::Base
597 597 end
598 598  
599 599 def portal_folders
600   - (settings[:portal_folders] || []).map{|fid| portal_community.articles.find(fid) }
  600 + (settings[:portal_folders] || []).map{|fid| portal_community.articles.find(:first, :conditions => { :id => fid }) }.compact
601 601 end
602 602  
603 603 def portal_folders=(folders)
... ...
test/unit/environment_test.rb
... ... @@ -803,6 +803,20 @@ class EnvironmentTest < Test::Unit::TestCase
803 803 assert_equal [], e.portal_folders
804 804 end
805 805  
  806 + should 'not crash when a portal folder is removed' do
  807 + e = Environment.default
  808 +
  809 + c = e.portal_community = fast_create(Community)
  810 + news_folder = fast_create(Folder, :name => 'news folder', :profile_id => c.id)
  811 +
  812 + e.portal_folders = [news_folder]
  813 + e.save!; e.reload
  814 +
  815 + news_folder.destroy
  816 +
  817 + assert_not_includes e.portal_folders, nil
  818 + end
  819 +
806 820 should 'have roles with names independent of other environments' do
807 821 e1 = fast_create(Environment)
808 822 role1 = Role.create!(:name => 'test_role', :environment => e1)
... ...