@@ -117,7 +117,6 class ProjectsController < ApplicationController | |||
|
117 | 117 | Mailer.with_deliveries(params[:notifications] == '1') do |
|
118 | 118 | @project = Project.new |
|
119 | 119 | @project.safe_attributes = params[:project] |
|
120 | @project.enabled_module_names = params[:enabled_modules] | |
|
121 | 120 | if validate_parent_id && @project.copy(@source_project, :only => params[:only]) |
|
122 | 121 | @project.set_allowed_parent!(params[:project]['parent_id']) if params[:project].has_key?('parent_id') |
|
123 | 122 | flash[:notice] = l(:notice_successful_create) |
@@ -448,7 +448,7 class ProjectsControllerTest < ActionController::TestCase | |||
|
448 | 448 | end |
|
449 | 449 | end |
|
450 | 450 | |
|
451 |
def test_copy |
|
|
451 | def test_get_copy | |
|
452 | 452 | @request.session[:user_id] = 1 # admin |
|
453 | 453 | get :copy, :id => 1 |
|
454 | 454 | assert_response :success |
@@ -456,15 +456,43 class ProjectsControllerTest < ActionController::TestCase | |||
|
456 | 456 | assert assigns(:project) |
|
457 | 457 | assert_equal Project.find(1).description, assigns(:project).description |
|
458 | 458 | assert_nil assigns(:project).id |
|
459 | ||
|
460 | assert_tag :tag => 'input', | |
|
461 | :attributes => {:name => 'project[enabled_module_names][]', :value => 'issue_tracking'} | |
|
459 | 462 | end |
|
460 | 463 | |
|
461 | def test_copy_without_project | |
|
464 | def test_get_copy_without_project | |
|
462 | 465 | @request.session[:user_id] = 1 # admin |
|
463 | 466 | get :copy |
|
464 | 467 | assert_response :redirect |
|
465 | 468 | assert_redirected_to :controller => 'admin', :action => 'projects' |
|
466 | 469 | end |
|
467 | 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 | |
|
495 | ||
|
468 | 496 | context "POST :copy" do |
|
469 | 497 | should "TODO: test the rest of the method" |
|
470 | 498 |
General Comments 0
You need to be logged in to leave comments.
Login now