From 182685eb2b62c217e7cfdd4d21cd4f9c8689a4ac Mon Sep 17 00:00:00 2001 From: Rodrigo Souto Date: Thu, 10 Apr 2014 19:08:32 +0000 Subject: [PATCH] [template-welcome-page] Not copy templates welcome-page --- app/models/profile.rb | 7 ++++++- test/unit/profile_test.rb | 10 ++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/app/models/profile.rb b/app/models/profile.rb index 764b36c..4557e11 100644 --- a/app/models/profile.rb +++ b/app/models/profile.rb @@ -605,7 +605,7 @@ private :generate_url, :url_options end def copy_article_tree(article, parent=nil) - return if article.is_a?(RssFeed) + return if !copy_article?(article) original_article = self.articles.find_by_name(article.name) if original_article num = 2 @@ -625,6 +625,11 @@ private :generate_url, :url_options end end + def copy_article?(article) + !article.is_a?(RssFeed) && + !(is_template && article.slug=='welcome-page') + end + # Adds a person as member of this Profile. def add_member(person) if self.has_members? diff --git a/test/unit/profile_test.rb b/test/unit/profile_test.rb index adedccc..420b51e 100644 --- a/test/unit/profile_test.rb +++ b/test/unit/profile_test.rb @@ -1955,4 +1955,14 @@ class ProfileTest < ActiveSupport::TestCase p = fast_create(Profile) assert p.folder_types.include?('ProfileTest::Folder1') end + + should 'not copy rss_feed' do + assert !fast_create(Profile).copy_article?(fast_create(RssFeed)) + end + + should 'not copy template welcome_page' do + template = fast_create(Person, :is_template => true) + welcome_page = fast_create(TinyMceArticle, :slug => 'welcome-page', :profile_id => template.id) + assert !template.copy_article?(welcome_page) + end end -- libgit2 0.21.2