Patch #26622 » 0003-Copy-project-attachments.patch
| app/models/project.rb | ||
|---|---|---|
| 827 | 827 |
Project.transaction do |
| 828 | 828 |
if save |
| 829 | 829 |
reload |
| 830 | ||
| 831 |
self.attachments = project.attachments.map do |attachment| |
|
| 832 |
attachment.copy(:container => self) |
|
| 833 |
end |
|
| 834 | ||
| 830 | 835 |
to_be_copied.each do |name| |
| 831 | 836 |
send "copy_#{name}", project
|
| 832 | 837 |
end |
| test/unit/project_copy_test.rb | ||
|---|---|---|
| 51 | 51 |
assert_equal false, project.copy(@source_project) |
| 52 | 52 |
end |
| 53 | 53 | |
| 54 |
test "#copy should copy project attachments" do |
|
| 55 |
Attachment.create!(:container => @source_project, :file => uploaded_test_file("testfile.txt", "text/plain"), :author_id => 1)
|
|
| 56 |
assert @project.copy(@source_project) |
|
| 57 | ||
| 58 |
assert_equal 1, @project.attachments.count, "Attachment not copied" |
|
| 59 |
assert_equal "testfile.txt", @project.attachments.first.filename |
|
| 60 |
end |
|
| 61 | ||
| 54 | 62 |
test "#copy should copy issues" do |
| 55 | 63 |
@source_project.issues << Issue.generate!(:status => IssueStatus.find_by_name('Closed'),
|
| 56 | 64 |
:subject => "copy issue status", |