diff --git a/app/models/profile.rb b/app/models/profile.rb index 9d1c54c..3273a17 100644 --- a/app/models/profile.rb +++ b/app/models/profile.rb @@ -356,6 +356,9 @@ class Profile < ActiveRecord::Base def copy_article_tree(article, parent=nil) article_copy = article.copy(:profile => self, :parent => parent) + if article.profile.home_page == article + self.home_page = article_copy + end article.children.each do |a| copy_article_tree a, article_copy end diff --git a/test/unit/profile_test.rb b/test/unit/profile_test.rb index f93ec3c..8306b99 100644 --- a/test/unit/profile_test.rb +++ b/test/unit/profile_test.rb @@ -839,7 +839,20 @@ class ProfileTest < Test::Unit::TestCase assert_equal 'some child article', child_art.name end - should 'copy homepage from template' + should 'copy homepage from template' do + template = create_user('test_template').person + template.articles.destroy_all + a1 = template.articles.create(:name => 'some xyz article') + template.home_page = a1 + template.save! + + Profile.any_instance.stubs(:template).returns(template) + + p = Profile.create!(:name => 'test_profile', :identifier => 'test_profile') + + assert_not_nil p.home_page + assert_equal 'some xyz article', p.home_page.name + end should 'copy set of boxes from profile template' do template = Profile.create!(:name => 'test template', :identifier => 'test_template') -- libgit2 0.21.2