@@ -683,6 +683,7 class Project < ActiveRecord::Base | |||||
683 | end |
|
683 | end | |
684 |
|
684 | |||
685 | # Copies issues from +project+ |
|
685 | # Copies issues from +project+ | |
|
686 | # Note: issues assigned to a closed version won't be copied due to validation rules | |||
686 | def copy_issues(project) |
|
687 | def copy_issues(project) | |
687 | # Stores the source issue id as a key and the copied issues as the |
|
688 | # Stores the source issue id as a key and the copied issues as the | |
688 | # value. Used to map the two togeather for issue relations. |
|
689 | # value. Used to map the two togeather for issue relations. |
@@ -464,16 +464,34 class ProjectsControllerTest < ActionController::TestCase | |||||
464 | assert_response :redirect |
|
464 | assert_response :redirect | |
465 | assert_redirected_to :controller => 'admin', :action => 'projects' |
|
465 | assert_redirected_to :controller => 'admin', :action => 'projects' | |
466 | end |
|
466 | end | |
467 |
|
467 | |||
468 | context "POST :copy" do |
|
468 | def test_post_copy_should_copy_requested_items | |
469 | should "TODO: test the rest of the method" |
|
469 | @request.session[:user_id] = 1 # admin | |
470 |
|
470 | CustomField.delete_all | ||
471 | should "redirect to the project settings when successful" do |
|
471 | ||
472 | @request.session[:user_id] = 1 # admin |
|
472 | assert_difference 'Project.count' do | |
473 | post :copy, :id => 1, :project => {:name => 'Copy', :identifier => 'unique-copy'} |
|
473 | post :copy, :id => 1, | |
474 | assert_response :redirect |
|
474 | :project => { | |
475 | assert_redirected_to :controller => 'projects', :action => 'settings', :id => 'unique-copy' |
|
475 | :name => 'Copy', | |
|
476 | :identifier => 'unique-copy', | |||
|
477 | :tracker_ids => ['1', '2', '3', ''], | |||
|
478 | :enabled_modules => %w(issue_tracking time_tracking) | |||
|
479 | }, | |||
|
480 | :only => %w(issues versions) | |||
476 | end |
|
481 | end | |
|
482 | project = Project.find('unique-copy') | |||
|
483 | source = Project.find(1) | |||
|
484 | assert_equal source.versions.count, project.versions.count, "All versions were not copied" | |||
|
485 | # issues assigned to a closed version won't be copied | |||
|
486 | assert_equal source.issues.select {|i| i.fixed_version.nil? || i.fixed_version.open?}.count, project.issues.count, "All issues were not copied" | |||
|
487 | assert_equal 0, project.members.count | |||
|
488 | end | |||
|
489 | ||||
|
490 | def test_post_copy_should_redirect_to_settings_when_successful | |||
|
491 | @request.session[:user_id] = 1 # admin | |||
|
492 | post :copy, :id => 1, :project => {:name => 'Copy', :identifier => 'unique-copy'} | |||
|
493 | assert_response :redirect | |||
|
494 | assert_redirected_to :controller => 'projects', :action => 'settings', :id => 'unique-copy' | |||
477 | end |
|
495 | end | |
478 |
|
496 | |||
479 | def test_jump_should_redirect_to_active_tab |
|
497 | def test_jump_should_redirect_to_active_tab |
General Comments 0
You need to be logged in to leave comments.
Login now