##// END OF EJS Templates
Adds functional test for project copy....
Jean-Philippe Lang -
r5235:c2d2761caaf0
parent child
Show More
@@ -683,6 +683,7 class Project < ActiveRecord::Base
683 683 end
684 684
685 685 # Copies issues from +project+
686 # Note: issues assigned to a closed version won't be copied due to validation rules
686 687 def copy_issues(project)
687 688 # Stores the source issue id as a key and the copied issues as the
688 689 # value. Used to map the two togeather for issue relations.
@@ -465,16 +465,34 class ProjectsControllerTest < ActionController::TestCase
465 465 assert_redirected_to :controller => 'admin', :action => 'projects'
466 466 end
467 467
468 context "POST :copy" do
469 should "TODO: test the rest of the method"
468 def test_post_copy_should_copy_requested_items
469 @request.session[:user_id] = 1 # admin
470 CustomField.delete_all
470 471
471 should "redirect to the project settings when successful" do
472 assert_difference 'Project.count' do
473 post :copy, :id => 1,
474 :project => {
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)
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
472 491 @request.session[:user_id] = 1 # admin
473 492 post :copy, :id => 1, :project => {:name => 'Copy', :identifier => 'unique-copy'}
474 493 assert_response :redirect
475 494 assert_redirected_to :controller => 'projects', :action => 'settings', :id => 'unique-copy'
476 495 end
477 end
478 496
479 497 def test_jump_should_redirect_to_active_tab
480 498 get :show, :id => 1, :jump => 'issues'
General Comments 0
You need to be logged in to leave comments. Login now