diff options
author | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2011-04-29 07:34:09 +0000 |
---|---|---|
committer | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2011-04-29 07:34:09 +0000 |
commit | e20191e666c9a2d6b35294bc09e316b8d489c649 (patch) | |
tree | d2f18a9bf562feb9434dc258bf6568fa33a234ac | |
parent | 8d3b32644b75f7c119b3424ed9bb12b756a0d271 (diff) | |
download | redmine-e20191e666c9a2d6b35294bc09e316b8d489c649.tar.gz redmine-e20191e666c9a2d6b35294bc09e316b8d489c649.zip |
Backported r5581 from trunk.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/branches/1.1-stable@5584 e93f8b46-1217-0410-a6f0-8f06a7374b81
-rw-r--r-- | app/controllers/projects_controller.rb | 1 | ||||
-rw-r--r-- | test/functional/projects_controller_test.rb | 32 |
2 files changed, 30 insertions, 3 deletions
diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index 459b54784..b6a37eb22 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -117,7 +117,6 @@ class ProjectsController < ApplicationController Mailer.with_deliveries(params[:notifications] == '1') do @project = Project.new @project.safe_attributes = params[:project] - @project.enabled_module_names = params[:enabled_modules] if validate_parent_id && @project.copy(@source_project, :only => params[:only]) @project.set_allowed_parent!(params[:project]['parent_id']) if params[:project].has_key?('parent_id') flash[:notice] = l(:notice_successful_create) diff --git a/test/functional/projects_controller_test.rb b/test/functional/projects_controller_test.rb index 74912a764..0cce03b32 100644 --- a/test/functional/projects_controller_test.rb +++ b/test/functional/projects_controller_test.rb @@ -448,7 +448,7 @@ class ProjectsControllerTest < ActionController::TestCase end end - def test_copy_with_project + def test_get_copy @request.session[:user_id] = 1 # admin get :copy, :id => 1 assert_response :success @@ -456,14 +456,42 @@ class ProjectsControllerTest < ActionController::TestCase assert assigns(:project) assert_equal Project.find(1).description, assigns(:project).description assert_nil assigns(:project).id + + assert_tag :tag => 'input', + :attributes => {:name => 'project[enabled_module_names][]', :value => 'issue_tracking'} end - def test_copy_without_project + def test_get_copy_without_project @request.session[:user_id] = 1 # admin get :copy assert_response :redirect assert_redirected_to :controller => 'admin', :action => 'projects' end + + def test_post_copy_should_copy_requested_items + @request.session[:user_id] = 1 # admin + CustomField.delete_all + + assert_difference 'Project.count' do + post :copy, :id => 1, + :project => { + :name => 'Copy', + :identifier => 'unique-copy', + :tracker_ids => ['1', '2', '3', ''], + :enabled_module_names => %w(issue_tracking time_tracking) + }, + :only => %w(issues versions) + end + project = Project.find('unique-copy') + source = Project.find(1) + assert_equal %w(issue_tracking time_tracking), project.enabled_module_names.sort + + assert_equal source.versions.count, project.versions.count, "All versions were not copied" + # issues assigned to a closed version won't be copied + assert_equal source.issues.select {|i| i.fixed_version.nil? || i.fixed_version.open?}.size, + project.issues.count, "All issues were not copied" + assert_equal 0, project.members.count + end context "POST :copy" do should "TODO: test the rest of the method" |