def copy_wiki(project)
# Check that the source project has a wiki first
unless project.wiki.nil?
- self.wiki ||= Wiki.new
+ wiki = self.wiki || Wiki.new
wiki.attributes = project.wiki.attributes.dup.except("id", "project_id")
wiki_pages_map = {}
project.wiki.pages.each do |page|
wiki.pages << new_wiki_page
wiki_pages_map[page.id] = new_wiki_page
end
+
+ self.wiki = wiki
wiki.save
# Reproduce page hierarchy
project.wiki.pages.each do |page|
assert_equal "Start page", @project.wiki.start_page
end
+ test "#copy should copy wiki without wiki module" do
+ project = Project.new(:name => 'Copy Test', :identifier => 'copy-test', :enabled_module_names => [])
+ assert_difference 'Wiki.count' do
+ assert project.copy(@source_project)
+ end
+
+ assert project.wiki
+ end
+
test "#copy should copy wiki pages and content with hierarchy" do
assert_difference 'WikiPage.count', @source_project.wiki.pages.size do
assert @project.copy(@source_project)