Project

General

Profile

Patch #26622 » 0003-Copy-project-attachments.patch

Holger Just, 2017-08-04 18:59

View differences:

app/models/project.rb
Project.transaction do
if save
reload
self.attachments = project.attachments.map do |attachment|
attachment.copy(:container => self)
end
to_be_copied.each do |name|
send "copy_#{name}", project
end
test/unit/project_copy_test.rb
assert_equal false, project.copy(@source_project)
end
test "#copy should copy project attachments" do
Attachment.create!(:container => @source_project, :file => uploaded_test_file("testfile.txt", "text/plain"), :author_id => 1)
assert @project.copy(@source_project)
assert_equal 1, @project.attachments.count, "Attachment not copied"
assert_equal "testfile.txt", @project.attachments.first.filename
end
test "#copy should copy issues" do
@source_project.issues << Issue.generate!(:status => IssueStatus.find_by_name('Closed'),
:subject => "copy issue status",
(2-2/5)