Commit 89736c33f46e8942c6c061e6685a89bebfbc2048
1 parent
b343396f
Exists in
master
and in
28 other branches
ActionItem591: copy homepage setting with article tree
git-svn-id: https://svn.colivre.coop.br/svn/noosfero/trunk@2451 3f533792-8f58-4932-b0fe-aaf55b0a4547
Showing
2 changed files
with
17 additions
and
1 deletions
Show diff stats
app/models/profile.rb
@@ -356,6 +356,9 @@ class Profile < ActiveRecord::Base | @@ -356,6 +356,9 @@ class Profile < ActiveRecord::Base | ||
356 | 356 | ||
357 | def copy_article_tree(article, parent=nil) | 357 | def copy_article_tree(article, parent=nil) |
358 | article_copy = article.copy(:profile => self, :parent => parent) | 358 | article_copy = article.copy(:profile => self, :parent => parent) |
359 | + if article.profile.home_page == article | ||
360 | + self.home_page = article_copy | ||
361 | + end | ||
359 | article.children.each do |a| | 362 | article.children.each do |a| |
360 | copy_article_tree a, article_copy | 363 | copy_article_tree a, article_copy |
361 | end | 364 | end |
test/unit/profile_test.rb
@@ -839,7 +839,20 @@ class ProfileTest < Test::Unit::TestCase | @@ -839,7 +839,20 @@ class ProfileTest < Test::Unit::TestCase | ||
839 | assert_equal 'some child article', child_art.name | 839 | assert_equal 'some child article', child_art.name |
840 | end | 840 | end |
841 | 841 | ||
842 | - should 'copy homepage from template' | 842 | + should 'copy homepage from template' do |
843 | + template = create_user('test_template').person | ||
844 | + template.articles.destroy_all | ||
845 | + a1 = template.articles.create(:name => 'some xyz article') | ||
846 | + template.home_page = a1 | ||
847 | + template.save! | ||
848 | + | ||
849 | + Profile.any_instance.stubs(:template).returns(template) | ||
850 | + | ||
851 | + p = Profile.create!(:name => 'test_profile', :identifier => 'test_profile') | ||
852 | + | ||
853 | + assert_not_nil p.home_page | ||
854 | + assert_equal 'some xyz article', p.home_page.name | ||
855 | + end | ||
843 | 856 | ||
844 | should 'copy set of boxes from profile template' do | 857 | should 'copy set of boxes from profile template' do |
845 | template = Profile.create!(:name => 'test template', :identifier => 'test_template') | 858 | template = Profile.create!(:name => 'test template', :identifier => 'test_template') |