@@ -117,7 +117,6 class ProjectsController < ApplicationController | |||||
117 | Mailer.with_deliveries(params[:notifications] == '1') do |
|
117 | Mailer.with_deliveries(params[:notifications] == '1') do | |
118 | @project = Project.new |
|
118 | @project = Project.new | |
119 | @project.safe_attributes = params[:project] |
|
119 | @project.safe_attributes = params[:project] | |
120 | @project.enabled_module_names = params[:enabled_modules] |
|
|||
121 | if validate_parent_id && @project.copy(@source_project, :only => params[:only]) |
|
120 | if validate_parent_id && @project.copy(@source_project, :only => params[:only]) | |
122 | @project.set_allowed_parent!(params[:project]['parent_id']) if params[:project].has_key?('parent_id') |
|
121 | @project.set_allowed_parent!(params[:project]['parent_id']) if params[:project].has_key?('parent_id') | |
123 | flash[:notice] = l(:notice_successful_create) |
|
122 | flash[:notice] = l(:notice_successful_create) |
@@ -448,7 +448,7 class ProjectsControllerTest < ActionController::TestCase | |||||
448 | end |
|
448 | end | |
449 | end |
|
449 | end | |
450 |
|
450 | |||
451 |
def test_copy |
|
451 | def test_get_copy | |
452 | @request.session[:user_id] = 1 # admin |
|
452 | @request.session[:user_id] = 1 # admin | |
453 | get :copy, :id => 1 |
|
453 | get :copy, :id => 1 | |
454 | assert_response :success |
|
454 | assert_response :success | |
@@ -456,14 +456,42 class ProjectsControllerTest < ActionController::TestCase | |||||
456 | assert assigns(:project) |
|
456 | assert assigns(:project) | |
457 | assert_equal Project.find(1).description, assigns(:project).description |
|
457 | assert_equal Project.find(1).description, assigns(:project).description | |
458 | assert_nil assigns(:project).id |
|
458 | assert_nil assigns(:project).id | |
|
459 | ||||
|
460 | assert_tag :tag => 'input', | |||
|
461 | :attributes => {:name => 'project[enabled_module_names][]', :value => 'issue_tracking'} | |||
459 | end |
|
462 | end | |
460 |
|
463 | |||
461 | def test_copy_without_project |
|
464 | def test_get_copy_without_project | |
462 | @request.session[:user_id] = 1 # admin |
|
465 | @request.session[:user_id] = 1 # admin | |
463 | get :copy |
|
466 | get :copy | |
464 | assert_response :redirect |
|
467 | assert_response :redirect | |
465 | assert_redirected_to :controller => 'admin', :action => 'projects' |
|
468 | assert_redirected_to :controller => 'admin', :action => 'projects' | |
466 | end |
|
469 | end | |
|
470 | ||||
|
471 | def test_post_copy_should_copy_requested_items | |||
|
472 | @request.session[:user_id] = 1 # admin | |||
|
473 | CustomField.delete_all | |||
|
474 | ||||
|
475 | assert_difference 'Project.count' do | |||
|
476 | post :copy, :id => 1, | |||
|
477 | :project => { | |||
|
478 | :name => 'Copy', | |||
|
479 | :identifier => 'unique-copy', | |||
|
480 | :tracker_ids => ['1', '2', '3', ''], | |||
|
481 | :enabled_module_names => %w(issue_tracking time_tracking) | |||
|
482 | }, | |||
|
483 | :only => %w(issues versions) | |||
|
484 | end | |||
|
485 | project = Project.find('unique-copy') | |||
|
486 | source = Project.find(1) | |||
|
487 | assert_equal %w(issue_tracking time_tracking), project.enabled_module_names.sort | |||
|
488 | ||||
|
489 | assert_equal source.versions.count, project.versions.count, "All versions were not copied" | |||
|
490 | # issues assigned to a closed version won't be copied | |||
|
491 | assert_equal source.issues.select {|i| i.fixed_version.nil? || i.fixed_version.open?}.size, | |||
|
492 | project.issues.count, "All issues were not copied" | |||
|
493 | assert_equal 0, project.members.count | |||
|
494 | end | |||
467 |
|
495 | |||
468 | context "POST :copy" do |
|
496 | context "POST :copy" do | |
469 | should "TODO: test the rest of the method" |
|
497 | should "TODO: test the rest of the method" |
General Comments 0
You need to be logged in to leave comments.
Login now