#183 Links copying
This commit is contained in:
parent
31be631a92
commit
57d16928cb
@ -202,11 +202,19 @@ class DmsfFolder < ActiveRecord::Base
|
||||
return new_folder unless new_folder.save
|
||||
|
||||
self.files.visible.each do |f|
|
||||
f.copy_to(project, new_folder)
|
||||
f.copy_to project, new_folder
|
||||
end
|
||||
|
||||
self.subfolders.each do |s|
|
||||
s.copy_to(project, new_folder)
|
||||
self.subfolders.visible.each do |s|
|
||||
s.copy_to project, new_folder
|
||||
end
|
||||
|
||||
self.folder_links.visible.each do |l|
|
||||
l.copy_to project, new_folder
|
||||
end
|
||||
|
||||
self.file_links.visible.each do |l|
|
||||
l.copy_to project, new_folder
|
||||
end
|
||||
|
||||
return new_folder
|
||||
|
||||
@ -84,5 +84,17 @@ class DmsfLink < ActiveRecord::Base
|
||||
end
|
||||
path
|
||||
end
|
||||
|
||||
def copy_to(project, folder)
|
||||
link = DmsfLink.new(
|
||||
:target_project_id => self.target_project_id,
|
||||
:target_id => self.target_id,
|
||||
:target_type => self.target_type,
|
||||
:name => self.name,
|
||||
:project_id => project.id,
|
||||
:dmsf_folder_id => folder.id)
|
||||
link.save
|
||||
link
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
@ -63,7 +63,6 @@
|
||||
<%= error_messages_for('file') %>
|
||||
<%= error_messages_for('revision') %>
|
||||
<%= render(:partial => 'file_new_revision') if User.current.allowed_to?(:file_manipulation, @file.project) %>
|
||||
<%#= form_tag('', :id => 'entries_form') %>
|
||||
|
||||
<h3><%= l(:heading_revisions) %></h3>
|
||||
<% @file.revisions.visible[@revision_pages.offset,@revision_pages.per_page].each do |revision| %>
|
||||
|
||||
@ -144,6 +144,28 @@ class DmsfLinksTest < RedmineDmsf::Test::UnitTest
|
||||
@folder_link.target_folder.dmsf_path_str
|
||||
end
|
||||
|
||||
def test_copy_to
|
||||
# File link
|
||||
file_link_copy = @file_link.copy_to @folder2.project, @folder2
|
||||
assert_not_nil file_link_copy
|
||||
assert_equal file_link_copy.target_project_id, @file_link.target_project_id
|
||||
assert_equal file_link_copy.target_id, @file_link.target_id
|
||||
assert_equal file_link_copy.target_type, @file_link.target_type
|
||||
assert_equal file_link_copy.name, @file_link.name
|
||||
assert_equal file_link_copy.project_id, @folder2.project.id
|
||||
assert_equal file_link_copy.dmsf_folder_id, @folder2.id
|
||||
|
||||
# Folder link
|
||||
folder_link_copy = @folder_link.copy_to @folder2.project, @folder2
|
||||
assert_not_nil folder_link_copy
|
||||
assert_equal folder_link_copy.target_project_id, @folder_link.target_project_id
|
||||
assert_equal folder_link_copy.target_id, @folder_link.target_id
|
||||
assert_equal folder_link_copy.target_type, @folder_link.target_type
|
||||
assert_equal folder_link_copy.name, @folder_link.name
|
||||
assert_equal folder_link_copy.project_id, @folder2.project.id
|
||||
assert_equal folder_link_copy.dmsf_folder_id, @folder2.id
|
||||
end
|
||||
|
||||
def test_destroy
|
||||
@folder_link.destroy
|
||||
assert_nil DmsfLink.find_by_id 1
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user