@@ -408,7 +408,7 class Project < ActiveRecord::Base | |||||
408 | def copy(project, options={}) |
|
408 | def copy(project, options={}) | |
409 | project = project.is_a?(Project) ? project : Project.find(project) |
|
409 | project = project.is_a?(Project) ? project : Project.find(project) | |
410 |
|
410 | |||
411 | to_be_copied = %w(wiki versions issue_categories issues members queries) |
|
411 | to_be_copied = %w(wiki versions issue_categories issues members queries boards) | |
412 | to_be_copied = to_be_copied & options[:only].to_a unless options[:only].nil? |
|
412 | to_be_copied = to_be_copied & options[:only].to_a unless options[:only].nil? | |
413 |
|
413 | |||
414 | Project.transaction do |
|
414 | Project.transaction do | |
@@ -522,6 +522,16 class Project < ActiveRecord::Base | |||||
522 | end |
|
522 | end | |
523 | end |
|
523 | end | |
524 |
|
524 | |||
|
525 | # Copies boards from +project+ | |||
|
526 | def copy_boards(project) | |||
|
527 | project.boards.each do |board| | |||
|
528 | new_board = Board.new | |||
|
529 | new_board.attributes = board.attributes.dup.except("id", "project_id", "topics_count", "messages_count", "last_message_id") | |||
|
530 | new_board.project = self | |||
|
531 | self.boards << new_board | |||
|
532 | end | |||
|
533 | end | |||
|
534 | ||||
525 | def allowed_permissions |
|
535 | def allowed_permissions | |
526 | @allowed_permissions ||= begin |
|
536 | @allowed_permissions ||= begin | |
527 | module_names = enabled_modules.collect {|m| m.name} |
|
537 | module_names = enabled_modules.collect {|m| m.name} |
@@ -18,6 +18,7 | |||||
18 | <label class="block"><%= check_box_tag 'only[]', 'issue_categories', true %> <%= l(:label_issue_category_plural) %> (<%= @source_project.issue_categories.count %>)</label> |
|
18 | <label class="block"><%= check_box_tag 'only[]', 'issue_categories', true %> <%= l(:label_issue_category_plural) %> (<%= @source_project.issue_categories.count %>)</label> | |
19 | <label class="block"><%= check_box_tag 'only[]', 'issues', true %> <%= l(:label_issue_plural) %> (<%= @source_project.issues.count %>)</label> |
|
19 | <label class="block"><%= check_box_tag 'only[]', 'issues', true %> <%= l(:label_issue_plural) %> (<%= @source_project.issues.count %>)</label> | |
20 | <label class="block"><%= check_box_tag 'only[]', 'queries', true %> <%= l(:label_query_plural) %> (<%= @source_project.queries.count %>)</label> |
|
20 | <label class="block"><%= check_box_tag 'only[]', 'queries', true %> <%= l(:label_query_plural) %> (<%= @source_project.queries.count %>)</label> | |
|
21 | <label class="block"><%= check_box_tag 'only[]', 'boards', true %> <%= l(:label_board_plural) %> (<%= @source_project.boards.count %>)</label> | |||
21 | <label class="block"><%= check_box_tag 'only[]', 'wiki', true %> <%= l(:label_wiki_page_plural) %> (<%= @source_project.wiki.nil? ? 0 : @source_project.wiki.pages.count %>)</label> |
|
22 | <label class="block"><%= check_box_tag 'only[]', 'wiki', true %> <%= l(:label_wiki_page_plural) %> (<%= @source_project.wiki.nil? ? 0 : @source_project.wiki.pages.count %>)</label> | |
22 | <%= hidden_field_tag 'only[]', '' %> |
|
23 | <%= hidden_field_tag 'only[]', '' %> | |
23 | </fieldset> |
|
24 | </fieldset> |
@@ -17,3 +17,12 boards_002: | |||||
17 | position: 2 |
|
17 | position: 2 | |
18 | last_message_id: |
|
18 | last_message_id: | |
19 | messages_count: 0 |
|
19 | messages_count: 0 | |
|
20 | boards_003: | |||
|
21 | name: Discussion | |||
|
22 | project_id: 2 | |||
|
23 | topics_count: 0 | |||
|
24 | id: 3 | |||
|
25 | description: Discussion board | |||
|
26 | position: 1 | |||
|
27 | last_message_id: | |||
|
28 | messages_count: 0 |
@@ -488,6 +488,15 class ProjectTest < ActiveSupport::TestCase | |||||
488 | end |
|
488 | end | |
489 | end |
|
489 | end | |
490 |
|
490 | |||
|
491 | should "copy boards" do | |||
|
492 | assert @project.copy(@source_project) | |||
|
493 | ||||
|
494 | assert_equal 1, @project.boards.size | |||
|
495 | @project.boards.each do |board| | |||
|
496 | assert !@source_project.boards.include?(board) | |||
|
497 | end | |||
|
498 | end | |||
|
499 | ||||
491 | should "change the new issues to use the copied issue categories" do |
|
500 | should "change the new issues to use the copied issue categories" do | |
492 | issue = Issue.find(4) |
|
501 | issue = Issue.find(4) | |
493 | issue.update_attribute(:category_id, 3) |
|
502 | issue.update_attribute(:category_id, 3) |
General Comments 0
You need to be logged in to leave comments.
Login now