Browse Source

Copy wiki attachments on project copy (#10282).

Patch by  Mizuki ISHIKAWA.


git-svn-id: http://svn.redmine.org/redmine/trunk@17315 e93f8b46-1217-0410-a6f0-8f06a7374b81
tags/4.0.0
Go MAEDA 6 years ago
parent
commit
07f0c2791e
2 changed files with 5 additions and 1 deletions
  1. 1
    0
      app/models/project.rb
  2. 4
    1
      test/unit/project_copy_test.rb

+ 1
- 0
app/models/project.rb View File

@@ -930,6 +930,7 @@ class Project < ActiveRecord::Base
new_wiki_page = WikiPage.new(page.attributes.dup.except("id", "wiki_id", "created_on", "parent_id"))
new_wiki_page.content = new_wiki_content
wiki.pages << new_wiki_page
new_wiki_page.attachments = page.attachments.map{|attachement| attachement.copy(:container => new_wiki_page)}
wiki_pages_map[page.id] = new_wiki_page
end


+ 4
- 1
test/unit/project_copy_test.rb View File

@@ -303,7 +303,8 @@ class ProjectCopyTest < ActiveSupport::TestCase
assert project.wiki
end

test "#copy should copy wiki pages and content with hierarchy" do
test "#copy should copy wiki pages, attachment and content with hierarchy" do
@source_project.wiki.pages.first.attachments << Attachment.first.copy
assert_difference 'WikiPage.count', @source_project.wiki.pages.size do
assert @project.copy(@source_project)
end
@@ -311,6 +312,8 @@ class ProjectCopyTest < ActiveSupport::TestCase
assert @project.wiki
assert_equal @source_project.wiki.pages.size, @project.wiki.pages.size

assert_equal @source_project.wiki.pages.first.attachments.first.filename, @project.wiki.pages.first.attachments.first.filename

@project.wiki.pages.each do |wiki_page|
assert wiki_page.content
assert !@source_project.wiki.pages.include?(wiki_page)

Loading…
Cancel
Save