Adds functional test for project copy.

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@5355 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Jean-Philippe Lang 2011-04-07 17:25:51 +00:00
parent d0ea5fae62
commit c2d2761caa
2 changed files with 28 additions and 9 deletions

View File

@ -683,6 +683,7 @@ class Project < ActiveRecord::Base
end
# Copies issues from +project+
# Note: issues assigned to a closed version won't be copied due to validation rules
def copy_issues(project)
# Stores the source issue id as a key and the copied issues as the
# value. Used to map the two togeather for issue relations.

View File

@ -464,16 +464,34 @@ class ProjectsControllerTest < ActionController::TestCase
assert_response :redirect
assert_redirected_to :controller => 'admin', :action => 'projects'
end
context "POST :copy" do
should "TODO: test the rest of the method"
should "redirect to the project settings when successful" do
@request.session[:user_id] = 1 # admin
post :copy, :id => 1, :project => {:name => 'Copy', :identifier => 'unique-copy'}
assert_response :redirect
assert_redirected_to :controller => 'projects', :action => 'settings', :id => 'unique-copy'
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_modules => %w(issue_tracking time_tracking)
},
:only => %w(issues versions)
end
project = Project.find('unique-copy')
source = Project.find(1)
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?}.count, project.issues.count, "All issues were not copied"
assert_equal 0, project.members.count
end
def test_post_copy_should_redirect_to_settings_when_successful
@request.session[:user_id] = 1 # admin
post :copy, :id => 1, :project => {:name => 'Copy', :identifier => 'unique-copy'}
assert_response :redirect
assert_redirected_to :controller => 'projects', :action => 'settings', :id => 'unique-copy'
end
def test_jump_should_redirect_to_active_tab