add_wiki_attachments_to_copy.patch

Mizuki ISHIKAWA, 2018-01-19 07:38

Download (1.63 KB)

View differences:

app/models/project.rb
930 930
        new_wiki_page = WikiPage.new(page.attributes.dup.except("id", "wiki_id", "created_on", "parent_id"))
931 931
        new_wiki_page.content = new_wiki_content
932 932
        wiki.pages << new_wiki_page
933
        new_wiki_page.attachments = page.attachments.map{|attachement| attachement.copy(:container => new_wiki_page)}
933 934
        wiki_pages_map[page.id] = new_wiki_page
934 935
      end
935 936

  
test/unit/project_copy_test.rb
303 303
    assert project.wiki
304 304
  end
305 305

  
306
  test "#copy should copy wiki pages and content with hierarchy" do
306
  test "#copy should copy wiki pages, attachment and content with hierarchy" do
307
    @source_project.wiki.pages.first.attachments << Attachment.first.copy
307 308
    assert_difference 'WikiPage.count', @source_project.wiki.pages.size do
308 309
      assert @project.copy(@source_project)
309 310
    end
......
311 312
    assert @project.wiki
312 313
    assert_equal @source_project.wiki.pages.size, @project.wiki.pages.size
313 314

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

  
314 317
    @project.wiki.pages.each do |wiki_page|
315 318
      assert wiki_page.content
316 319
      assert !@source_project.wiki.pages.include?(wiki_page)