@@ -408,7 +408,7 class Project < ActiveRecord::Base | |||
|
408 | 408 | def copy(project, options={}) |
|
409 | 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 | 412 | to_be_copied = to_be_copied & options[:only].to_a unless options[:only].nil? |
|
413 | 413 | |
|
414 | 414 | Project.transaction do |
@@ -521,6 +521,16 class Project < ActiveRecord::Base | |||
|
521 | 521 | self.queries << new_query |
|
522 | 522 | end |
|
523 | 523 | end |
|
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 | |
|
524 | 534 | |
|
525 | 535 | def allowed_permissions |
|
526 | 536 | @allowed_permissions ||= begin |
@@ -18,6 +18,7 | |||
|
18 | 18 | <label class="block"><%= check_box_tag 'only[]', 'issue_categories', true %> <%= l(:label_issue_category_plural) %> (<%= @source_project.issue_categories.count %>)</label> |
|
19 | 19 | <label class="block"><%= check_box_tag 'only[]', 'issues', true %> <%= l(:label_issue_plural) %> (<%= @source_project.issues.count %>)</label> |
|
20 | 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 | 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 | 23 | <%= hidden_field_tag 'only[]', '' %> |
|
23 | 24 | </fieldset> |
@@ -17,3 +17,12 boards_002: | |||
|
17 | 17 | position: 2 |
|
18 | 18 | last_message_id: |
|
19 | 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 | 488 | end |
|
489 | 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 | 500 | should "change the new issues to use the copied issue categories" do |
|
492 | 501 | issue = Issue.find(4) |
|
493 | 502 | issue.update_attribute(:category_id, 3) |
General Comments 0
You need to be logged in to leave comments.
Login now