summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2010-03-13 14:56:49 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2010-03-13 14:56:49 +0000
commit8e3d1b694ab47317638b474082cb70e08a8d02e7 (patch)
tree9997cc24910a029fea3e98ed0765566d9c4bb97e /test
parente109c9b6b6f314dea19bf92dffa217d962eaa200 (diff)
downloadredmine-8e3d1b694ab47317638b474082cb70e08a8d02e7.tar.gz
redmine-8e3d1b694ab47317638b474082cb70e08a8d02e7.zip
Adds subtasking (#443) including:
* priority, start/due dates, progress, estimate, spent time roll-up to parent issues * descendant issues tree displayed on the issue view with context menu support * issue tree display on the gantt chart * issue tree copy on project copy * unlimited nesting Defining subtasks requires the new permission 'Manage subtasks'. Subtasks can not belong to a different project than the parent task. Implementation is based on scoped nested sets for fast reads and updates. git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@3573 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'test')
-rw-r--r--test/fixtures/enumerations.yml5
-rw-r--r--test/fixtures/issues.yml39
-rw-r--r--test/fixtures/roles.yml2
-rw-r--r--test/functional/issues_controller_test.rb44
-rw-r--r--test/unit/issue_nested_set_test.rb300
-rw-r--r--test/unit/issue_test.rb31
6 files changed, 405 insertions, 16 deletions
diff --git a/test/fixtures/enumerations.yml b/test/fixtures/enumerations.yml
index 650a48c3e..c4a25d954 100644
--- a/test/fixtures/enumerations.yml
+++ b/test/fixtures/enumerations.yml
@@ -19,27 +19,32 @@ enumerations_004:
id: 4
type: IssuePriority
active: true
+ position: 1
enumerations_005:
name: Normal
id: 5
type: IssuePriority
is_default: true
active: true
+ position: 2
enumerations_006:
name: High
id: 6
type: IssuePriority
active: true
+ position: 3
enumerations_007:
name: Urgent
id: 7
type: IssuePriority
active: true
+ position: 4
enumerations_008:
name: Immediate
id: 8
type: IssuePriority
active: true
+ position: 5
enumerations_009:
name: Design
id: 9
diff --git a/test/fixtures/issues.yml b/test/fixtures/issues.yml
index 4b61b41a3..6ec671e58 100644
--- a/test/fixtures/issues.yml
+++ b/test/fixtures/issues.yml
@@ -15,6 +15,9 @@ issues_001:
status_id: 1
start_date: <%= 1.day.ago.to_date.to_s(:db) %>
due_date: <%= 10.day.from_now.to_date.to_s(:db) %>
+ root_id: 1
+ lft: 1
+ rgt: 2
issues_002:
created_on: 2006-07-19 21:04:21 +02:00
project_id: 1
@@ -31,6 +34,9 @@ issues_002:
status_id: 2
start_date: <%= 2.day.ago.to_date.to_s(:db) %>
due_date:
+ root_id: 2
+ lft: 1
+ rgt: 2
issues_003:
created_on: 2006-07-19 21:07:27 +02:00
project_id: 1
@@ -47,6 +53,9 @@ issues_003:
status_id: 1
start_date: <%= 1.day.from_now.to_date.to_s(:db) %>
due_date: <%= 40.day.ago.to_date.to_s(:db) %>
+ root_id: 3
+ lft: 1
+ rgt: 2
issues_004:
created_on: <%= 5.days.ago.to_date.to_s(:db) %>
project_id: 2
@@ -61,6 +70,9 @@ issues_004:
assigned_to_id: 2
author_id: 2
status_id: 1
+ root_id: 4
+ lft: 1
+ rgt: 2
issues_005:
created_on: <%= 5.days.ago.to_date.to_s(:db) %>
project_id: 3
@@ -75,6 +87,9 @@ issues_005:
assigned_to_id:
author_id: 2
status_id: 1
+ root_id: 5
+ lft: 1
+ rgt: 2
issues_006:
created_on: <%= 1.minute.ago.to_date.to_s(:db) %>
project_id: 5
@@ -91,6 +106,9 @@ issues_006:
status_id: 1
start_date: <%= Date.today.to_s(:db) %>
due_date: <%= 1.days.from_now.to_date.to_s(:db) %>
+ root_id: 6
+ lft: 1
+ rgt: 2
issues_007:
created_on: <%= 10.days.ago.to_date.to_s(:db) %>
project_id: 1
@@ -108,6 +126,9 @@ issues_007:
start_date: <%= 10.days.ago.to_s(:db) %>
due_date: <%= Date.today.to_s(:db) %>
lock_version: 0
+ root_id: 7
+ lft: 1
+ rgt: 2
issues_008:
created_on: <%= 10.days.ago.to_date.to_s(:db) %>
project_id: 1
@@ -125,6 +146,9 @@ issues_008:
start_date:
due_date:
lock_version: 0
+ root_id: 8
+ lft: 1
+ rgt: 2
issues_009:
created_on: <%= 1.minute.ago.to_date.to_s(:db) %>
project_id: 5
@@ -141,6 +165,9 @@ issues_009:
status_id: 1
start_date: <%= Date.today.to_s(:db) %>
due_date: <%= 1.days.from_now.to_date.to_s(:db) %>
+ root_id: 9
+ lft: 1
+ rgt: 2
issues_010:
created_on: <%= 1.minute.ago.to_date.to_s(:db) %>
project_id: 5
@@ -157,6 +184,9 @@ issues_010:
status_id: 1
start_date: <%= Date.today.to_s(:db) %>
due_date: <%= 1.days.from_now.to_date.to_s(:db) %>
+ root_id: 10
+ lft: 1
+ rgt: 2
issues_011:
created_on: <%= 3.days.ago.to_date.to_s(:db) %>
project_id: 1
@@ -173,6 +203,9 @@ issues_011:
status_id: 5
start_date: <%= 1.day.ago.to_date.to_s(:db) %>
due_date:
+ root_id: 11
+ lft: 1
+ rgt: 2
issues_012:
created_on: <%= 3.days.ago.to_date.to_s(:db) %>
project_id: 1
@@ -189,6 +222,9 @@ issues_012:
status_id: 5
start_date: <%= 1.day.ago.to_date.to_s(:db) %>
due_date:
+ root_id: 12
+ lft: 1
+ rgt: 2
issues_013:
created_on: <%= 5.days.ago.to_date.to_s(:db) %>
project_id: 3
@@ -203,3 +239,6 @@ issues_013:
assigned_to_id:
author_id: 2
status_id: 1
+ root_id: 13
+ lft: 1
+ rgt: 2
diff --git a/test/fixtures/roles.yml b/test/fixtures/roles.yml
index e3dc3645f..f63203ae3 100644
--- a/test/fixtures/roles.yml
+++ b/test/fixtures/roles.yml
@@ -14,6 +14,7 @@ roles_001:
- :add_issues
- :edit_issues
- :manage_issue_relations
+ - :manage_subtasks
- :add_issue_notes
- :move_issues
- :delete_issues
@@ -66,6 +67,7 @@ roles_002:
- :add_issues
- :edit_issues
- :manage_issue_relations
+ - :manage_subtasks
- :add_issue_notes
- :move_issues
- :delete_issues
diff --git a/test/functional/issues_controller_test.rb b/test/functional/issues_controller_test.rb
index b2f75eaba..11d35f500 100644
--- a/test/functional/issues_controller_test.rb
+++ b/test/functional/issues_controller_test.rb
@@ -476,7 +476,7 @@ class IssuesControllerTest < ActionController::TestCase
:subject => 'This is first issue',
:priority_id => 5},
:continue => ''
- assert_redirected_to :controller => 'issues', :action => 'new', :tracker_id => 3
+ assert_redirected_to :controller => 'issues', :action => 'new', :issue => {:tracker_id => 3}
end
def test_post_new_without_custom_fields_param
@@ -533,6 +533,20 @@ class IssuesControllerTest < ActionController::TestCase
assert [mail.bcc, mail.cc].flatten.include?(User.find(3).mail)
end
+ def test_post_new_subissue
+ @request.session[:user_id] = 2
+
+ assert_difference 'Issue.count' do
+ post :new, :project_id => 1,
+ :issue => {:tracker_id => 1,
+ :subject => 'This is a child issue',
+ :parent_issue_id => 2}
+ end
+ issue = Issue.find_by_subject('This is a child issue')
+ assert_not_nil issue
+ assert_equal Issue.find(2), issue.parent
+ end
+
def test_post_new_should_send_a_notification
ActionMailer::Base.deliveries.clear
@request.session[:user_id] = 2
@@ -1214,6 +1228,34 @@ class IssuesControllerTest < ActionController::TestCase
:attributes => { :href => '#',
:class => 'icon-del disabled' }
end
+
+ def test_auto_complete_routing
+ assert_routing(
+ {:method => :get, :path => '/issues/auto_complete'},
+ :controller => 'issues', :action => 'auto_complete'
+ )
+ end
+
+ def test_auto_complete_should_not_be_case_sensitive
+ get :auto_complete, :project_id => 'ecookbook', :q => 'ReCiPe'
+ assert_response :success
+ assert_not_nil assigns(:issues)
+ assert assigns(:issues).detect {|issue| issue.subject.match /recipe/}
+ end
+
+ def test_auto_complete_should_return_issue_with_given_id
+ get :auto_complete, :project_id => 'subproject1', :q => '13'
+ assert_response :success
+ assert_not_nil assigns(:issues)
+ assert assigns(:issues).include?(Issue.find(13))
+ end
+
+ def test_destroy_routing
+ assert_recognizes( #TODO: use DELETE on issue URI (need to change forms)
+ {:controller => 'issues', :action => 'destroy', :id => '1'},
+ {:method => :post, :path => '/issues/1/destroy'}
+ )
+ end
def test_destroy_issue_with_no_time_entries
assert_nil TimeEntry.find_by_issue_id(2)
diff --git a/test/unit/issue_nested_set_test.rb b/test/unit/issue_nested_set_test.rb
new file mode 100644
index 000000000..d82a42d28
--- /dev/null
+++ b/test/unit/issue_nested_set_test.rb
@@ -0,0 +1,300 @@
+# redMine - project management software
+# Copyright (C) 2006-2007 Jean-Philippe Lang
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+require File.dirname(__FILE__) + '/../test_helper'
+
+class IssueNestedSetTest < ActiveSupport::TestCase
+ fixtures :projects, :users, :members, :member_roles, :roles,
+ :trackers, :projects_trackers,
+ :versions,
+ :issue_statuses, :issue_categories, :issue_relations, :workflows,
+ :enumerations,
+ :issues,
+ :custom_fields, :custom_fields_projects, :custom_fields_trackers, :custom_values,
+ :time_entries
+
+ self.use_transactional_fixtures = false
+
+ def test_create_root_issue
+ issue1 = create_issue!
+ issue2 = create_issue!
+ issue1.reload
+ issue2.reload
+
+ assert_equal [issue1.id, nil, 1, 2], [issue1.root_id, issue1.parent_id, issue1.lft, issue1.rgt]
+ assert_equal [issue2.id, nil, 1, 2], [issue2.root_id, issue2.parent_id, issue2.lft, issue2.rgt]
+ end
+
+ def test_create_child_issue
+ parent = create_issue!
+ child = create_issue!(:parent_issue_id => parent.id)
+ parent.reload
+ child.reload
+
+ assert_equal [parent.id, nil, 1, 4], [parent.root_id, parent.parent_id, parent.lft, parent.rgt]
+ assert_equal [parent.id, parent.id, 2, 3], [child.root_id, child.parent_id, child.lft, child.rgt]
+ end
+
+ def test_creating_a_child_in_different_project_should_not_validate
+ issue = create_issue!
+ child = Issue.new(:project_id => 2, :tracker_id => 1, :author_id => 1, :subject => 'child', :parent_issue_id => issue.id)
+ assert !child.save
+ assert_not_nil child.errors.on(:parent_issue_id)
+ end
+
+ def test_move_a_root_to_child
+ parent1 = create_issue!
+ parent2 = create_issue!
+ child = create_issue!(:parent_issue_id => parent1.id)
+
+ parent2.parent_issue_id = parent1.id
+ parent2.save!
+ child.reload
+ parent1.reload
+ parent2.reload
+
+ assert_equal [parent1.id, 1, 6], [parent1.root_id, parent1.lft, parent1.rgt]
+ assert_equal [parent1.id, 4, 5], [parent2.root_id, parent2.lft, parent2.rgt]
+ assert_equal [parent1.id, 2, 3], [child.root_id, child.lft, child.rgt]
+ end
+
+ def test_move_a_child_to_root
+ parent1 = create_issue!
+ parent2 = create_issue!
+ child = create_issue!(:parent_issue_id => parent1.id)
+
+ child.parent_issue_id = nil
+ child.save!
+ child.reload
+ parent1.reload
+ parent2.reload
+
+ assert_equal [parent1.id, 1, 2], [parent1.root_id, parent1.lft, parent1.rgt]
+ assert_equal [parent2.id, 1, 2], [parent2.root_id, parent2.lft, parent2.rgt]
+ assert_equal [child.id, 1, 2], [child.root_id, child.lft, child.rgt]
+ end
+
+ def test_move_a_child_to_another_issue
+ parent1 = create_issue!
+ parent2 = create_issue!
+ child = create_issue!(:parent_issue_id => parent1.id)
+
+ child.parent_issue_id = parent2.id
+ child.save!
+ child.reload
+ parent1.reload
+ parent2.reload
+
+ assert_equal [parent1.id, 1, 2], [parent1.root_id, parent1.lft, parent1.rgt]
+ assert_equal [parent2.id, 1, 4], [parent2.root_id, parent2.lft, parent2.rgt]
+ assert_equal [parent2.id, 2, 3], [child.root_id, child.lft, child.rgt]
+ end
+
+ def test_move_a_child_with_descendants_to_another_issue
+ parent1 = create_issue!
+ parent2 = create_issue!
+ child = create_issue!(:parent_issue_id => parent1.id)
+ grandchild = create_issue!(:parent_issue_id => child.id)
+
+ parent1.reload
+ parent2.reload
+ child.reload
+ grandchild.reload
+
+ assert_equal [parent1.id, 1, 6], [parent1.root_id, parent1.lft, parent1.rgt]
+ assert_equal [parent2.id, 1, 2], [parent2.root_id, parent2.lft, parent2.rgt]
+ assert_equal [parent1.id, 2, 5], [child.root_id, child.lft, child.rgt]
+ assert_equal [parent1.id, 3, 4], [grandchild.root_id, grandchild.lft, grandchild.rgt]
+
+ child.reload.parent_issue_id = parent2.id
+ child.save!
+ child.reload
+ grandchild.reload
+ parent1.reload
+ parent2.reload
+
+ assert_equal [parent1.id, 1, 2], [parent1.root_id, parent1.lft, parent1.rgt]
+ assert_equal [parent2.id, 1, 6], [parent2.root_id, parent2.lft, parent2.rgt]
+ assert_equal [parent2.id, 2, 5], [child.root_id, child.lft, child.rgt]
+ assert_equal [parent2.id, 3, 4], [grandchild.root_id, grandchild.lft, grandchild.rgt]
+ end
+
+ def test_move_a_child_with_descendants_to_another_project
+ parent1 = create_issue!
+ child = create_issue!(:parent_issue_id => parent1.id)
+ grandchild = create_issue!(:parent_issue_id => child.id)
+
+ assert child.reload.move_to_project(Project.find(2))
+ child.reload
+ grandchild.reload
+ parent1.reload
+
+ assert_equal [1, parent1.id, 1, 2], [parent1.project_id, parent1.root_id, parent1.lft, parent1.rgt]
+ assert_equal [2, child.id, 1, 4], [child.project_id, child.root_id, child.lft, child.rgt]
+ assert_equal [2, child.id, 2, 3], [grandchild.project_id, grandchild.root_id, grandchild.lft, grandchild.rgt]
+ end
+
+ def test_invalid_move_to_another_project
+ parent1 = create_issue!
+ child = create_issue!(:parent_issue_id => parent1.id)
+ grandchild = create_issue!(:parent_issue_id => child.id, :tracker_id => 2)
+ Project.find(2).tracker_ids = [1]
+
+ parent1.reload
+ assert_equal [1, parent1.id, 1, 6], [parent1.project_id, parent1.root_id, parent1.lft, parent1.rgt]
+
+ # child can not be moved to Project 2 because its child is on a disabled tracker
+ assert_equal false, Issue.find(child.id).move_to_project(Project.find(2))
+ child.reload
+ grandchild.reload
+ parent1.reload
+
+ # no change
+ assert_equal [1, parent1.id, 1, 6], [parent1.project_id, parent1.root_id, parent1.lft, parent1.rgt]
+ assert_equal [1, parent1.id, 2, 5], [child.project_id, child.root_id, child.lft, child.rgt]
+ assert_equal [1, parent1.id, 3, 4], [grandchild.project_id, grandchild.root_id, grandchild.lft, grandchild.rgt]
+ end
+
+ def test_moving_an_issue_to_a_descendant_should_not_validate
+ parent1 = create_issue!
+ parent2 = create_issue!
+ child = create_issue!(:parent_issue_id => parent1.id)
+ grandchild = create_issue!(:parent_issue_id => child.id)
+
+ child.reload
+ child.parent_issue_id = grandchild.id
+ assert !child.save
+ assert_not_nil child.errors.on(:parent_issue_id)
+ end
+
+ def test_moving_an_issue_should_keep_valid_relations_only
+ issue1 = create_issue!
+ issue2 = create_issue!
+ issue3 = create_issue!(:parent_issue_id => issue2.id)
+ issue4 = create_issue!
+ r1 = IssueRelation.create!(:issue_from => issue1, :issue_to => issue2, :relation_type => IssueRelation::TYPE_PRECEDES)
+ r2 = IssueRelation.create!(:issue_from => issue1, :issue_to => issue3, :relation_type => IssueRelation::TYPE_PRECEDES)
+ r3 = IssueRelation.create!(:issue_from => issue2, :issue_to => issue4, :relation_type => IssueRelation::TYPE_PRECEDES)
+ issue2.reload
+ issue2.parent_issue_id = issue1.id
+ issue2.save!
+ assert !IssueRelation.exists?(r1.id)
+ assert !IssueRelation.exists?(r2.id)
+ assert IssueRelation.exists?(r3.id)
+ end
+
+ def test_destroy_should_destroy_children
+ issue1 = create_issue!
+ issue2 = create_issue!
+ issue3 = create_issue!(:parent_issue_id => issue2.id)
+ issue4 = create_issue!(:parent_issue_id => issue1.id)
+ issue2.reload.destroy
+ issue1.reload
+ issue4.reload
+ assert !Issue.exists?(issue2.id)
+ assert !Issue.exists?(issue3.id)
+ assert_equal [issue1.id, 1, 4], [issue1.root_id, issue1.lft, issue1.rgt]
+ assert_equal [issue1.id, 2, 3], [issue4.root_id, issue4.lft, issue4.rgt]
+ end
+
+ def test_parent_priority_should_be_the_highest_child_priority
+ parent = create_issue!(:priority => IssuePriority.find_by_name('Normal'))
+ # Create children
+ child1 = create_issue!(:priority => IssuePriority.find_by_name('High'), :parent_issue_id => parent.id)
+ assert_equal 'High', parent.reload.priority.name
+ child2 = create_issue!(:priority => IssuePriority.find_by_name('Immediate'), :parent_issue_id => child1.id)
+ assert_equal 'Immediate', child1.reload.priority.name
+ assert_equal 'Immediate', parent.reload.priority.name
+ child3 = create_issue!(:priority => IssuePriority.find_by_name('Low'), :parent_issue_id => parent.id)
+ assert_equal 'Immediate', parent.reload.priority.name
+ # Destroy a child
+ child1.destroy
+ assert_equal 'Low', parent.reload.priority.name
+ # Update a child
+ child3.reload.priority = IssuePriority.find_by_name('Normal')
+ child3.save!
+ assert_equal 'Normal', parent.reload.priority.name
+ end
+
+ def test_parent_dates_should_be_lowest_start_and_highest_due_dates
+ parent = create_issue!
+ create_issue!(:start_date => '2010-01-25', :due_date => '2010-02-15', :parent_issue_id => parent.id)
+ create_issue!( :due_date => '2010-02-13', :parent_issue_id => parent.id)
+ create_issue!(:start_date => '2010-02-01', :due_date => '2010-02-22', :parent_issue_id => parent.id)
+ parent.reload
+ assert_equal Date.parse('2010-01-25'), parent.start_date
+ assert_equal Date.parse('2010-02-22'), parent.due_date
+ end
+
+ def test_parent_done_ratio_should_be_average_done_ratio_of_leaves
+ parent = create_issue!
+ create_issue!(:done_ratio => 20, :parent_issue_id => parent.id)
+ assert_equal 20, parent.reload.done_ratio
+ create_issue!(:done_ratio => 70, :parent_issue_id => parent.id)
+ assert_equal 45, parent.reload.done_ratio
+
+ child = create_issue!(:done_ratio => 0, :parent_issue_id => parent.id)
+ assert_equal 30, parent.reload.done_ratio
+
+ create_issue!(:done_ratio => 30, :parent_issue_id => child.id)
+ assert_equal 30, child.reload.done_ratio
+ assert_equal 40, parent.reload.done_ratio
+ end
+
+ def test_parent_done_ratio_should_be_weighted_by_estimated_times_if_any
+ parent = create_issue!
+ create_issue!(:estimated_hours => 10, :done_ratio => 20, :parent_issue_id => parent.id)
+ assert_equal 20, parent.reload.done_ratio
+ create_issue!(:estimated_hours => 20, :done_ratio => 50, :parent_issue_id => parent.id)
+ assert_equal (50 * 20 + 20 * 10) / 30, parent.reload.done_ratio
+ end
+
+ def test_parent_estimate_should_be_sum_of_leaves
+ parent = create_issue!
+ create_issue!(:estimated_hours => nil, :parent_issue_id => parent.id)
+ assert_equal nil, parent.reload.estimated_hours
+ create_issue!(:estimated_hours => 5, :parent_issue_id => parent.id)
+ assert_equal 5, parent.reload.estimated_hours
+ create_issue!(:estimated_hours => 7, :parent_issue_id => parent.id)
+ assert_equal 12, parent.reload.estimated_hours
+ end
+
+ def test_project_copy_should_copy_issue_tree
+ p = Project.create!(:name => 'Tree copy', :identifier => 'tree-copy', :tracker_ids => [1, 2])
+ i1 = create_issue!(:project_id => p.id, :subject => 'i1')
+ i2 = create_issue!(:project_id => p.id, :subject => 'i2', :parent_issue_id => i1.id)
+ i3 = create_issue!(:project_id => p.id, :subject => 'i3', :parent_issue_id => i1.id)
+ i4 = create_issue!(:project_id => p.id, :subject => 'i4', :parent_issue_id => i2.id)
+ i5 = create_issue!(:project_id => p.id, :subject => 'i5')
+ c = Project.new(:name => 'Copy', :identifier => 'copy', :tracker_ids => [1, 2])
+ c.copy(p, :only => 'issues')
+ c.reload
+
+ assert_equal 5, c.issues.count
+ ic1, ic2, ic3, ic4, ic5 = c.issues.find(:all, :order => 'subject')
+ assert ic1.root?
+ assert_equal ic1, ic2.parent
+ assert_equal ic1, ic3.parent
+ assert_equal ic2, ic4.parent
+ assert ic5.root?
+ end
+
+ # Helper that creates an issue with default attributes
+ def create_issue!(attributes={})
+ Issue.create!({:project_id => 1, :tracker_id => 1, :author_id => 1, :subject => 'test'}.merge(attributes))
+ end
+end
diff --git a/test/unit/issue_test.rb b/test/unit/issue_test.rb
index cf5369726..de53125f5 100644
--- a/test/unit/issue_test.rb
+++ b/test/unit/issue_test.rb
@@ -329,7 +329,7 @@ class IssueTest < ActiveSupport::TestCase
def test_move_to_another_project_with_same_category
issue = Issue.find(1)
- assert issue.move_to(Project.find(2))
+ assert issue.move_to_project(Project.find(2))
issue.reload
assert_equal 2, issue.project_id
# Category changes
@@ -340,7 +340,7 @@ class IssueTest < ActiveSupport::TestCase
def test_move_to_another_project_without_same_category
issue = Issue.find(2)
- assert issue.move_to(Project.find(2))
+ assert issue.move_to_project(Project.find(2))
issue.reload
assert_equal 2, issue.project_id
# Category cleared
@@ -350,7 +350,7 @@ class IssueTest < ActiveSupport::TestCase
def test_move_to_another_project_should_clear_fixed_version_when_not_shared
issue = Issue.find(1)
issue.update_attribute(:fixed_version_id, 1)
- assert issue.move_to(Project.find(2))
+ assert issue.move_to_project(Project.find(2))
issue.reload
assert_equal 2, issue.project_id
# Cleared fixed_version
@@ -360,7 +360,7 @@ class IssueTest < ActiveSupport::TestCase
def test_move_to_another_project_should_keep_fixed_version_when_shared_with_the_target_project
issue = Issue.find(1)
issue.update_attribute(:fixed_version_id, 4)
- assert issue.move_to(Project.find(5))
+ assert issue.move_to_project(Project.find(5))
issue.reload
assert_equal 5, issue.project_id
# Keep fixed_version
@@ -370,7 +370,7 @@ class IssueTest < ActiveSupport::TestCase
def test_move_to_another_project_should_clear_fixed_version_when_not_shared_with_the_target_project
issue = Issue.find(1)
issue.update_attribute(:fixed_version_id, 1)
- assert issue.move_to(Project.find(5))
+ assert issue.move_to_project(Project.find(5))
issue.reload
assert_equal 5, issue.project_id
# Cleared fixed_version
@@ -380,7 +380,7 @@ class IssueTest < ActiveSupport::TestCase
def test_move_to_another_project_should_keep_fixed_version_when_shared_systemwide
issue = Issue.find(1)
issue.update_attribute(:fixed_version_id, 7)
- assert issue.move_to(Project.find(2))
+ assert issue.move_to_project(Project.find(2))
issue.reload
assert_equal 2, issue.project_id
# Keep fixed_version
@@ -392,7 +392,7 @@ class IssueTest < ActiveSupport::TestCase
target = Project.find(2)
target.tracker_ids = [3]
target.save
- assert_equal false, issue.move_to(target)
+ assert_equal false, issue.move_to_project(target)
issue.reload
assert_equal 1, issue.project_id
end
@@ -401,7 +401,7 @@ class IssueTest < ActiveSupport::TestCase
issue = Issue.find(1)
copy = nil
assert_difference 'Issue.count' do
- copy = issue.move_to(issue.project, nil, :copy => true)
+ copy = issue.move_to_project(issue.project, nil, :copy => true)
end
assert_kind_of Issue, copy
assert_equal issue.project, copy.project
@@ -412,8 +412,9 @@ class IssueTest < ActiveSupport::TestCase
issue = Issue.find(1)
copy = nil
assert_difference 'Issue.count' do
- copy = issue.move_to(Project.find(3), Tracker.find(2), :copy => true)
+ copy = issue.move_to_project(Project.find(3), Tracker.find(2), :copy => true)
end
+ copy.reload
assert_kind_of Issue, copy
assert_equal Project.find(3), copy.project
assert_equal Tracker.find(2), copy.tracker
@@ -421,7 +422,7 @@ class IssueTest < ActiveSupport::TestCase
assert_nil copy.custom_value_for(2)
end
- context "#move_to" do
+ context "#move_to_project" do
context "as a copy" do
setup do
@issue = Issue.find(1)
@@ -429,24 +430,24 @@ class IssueTest < ActiveSupport::TestCase
end
should "allow assigned_to changes" do
- @copy = @issue.move_to(Project.find(3), Tracker.find(2), {:copy => true, :attributes => {:assigned_to_id => 3}})
+ @copy = @issue.move_to_project(Project.find(3), Tracker.find(2), {:copy => true, :attributes => {:assigned_to_id => 3}})
assert_equal 3, @copy.assigned_to_id
end
should "allow status changes" do
- @copy = @issue.move_to(Project.find(3), Tracker.find(2), {:copy => true, :attributes => {:status_id => 2}})
+ @copy = @issue.move_to_project(Project.find(3), Tracker.find(2), {:copy => true, :attributes => {:status_id => 2}})
assert_equal 2, @copy.status_id
end
should "allow start date changes" do
date = Date.today
- @copy = @issue.move_to(Project.find(3), Tracker.find(2), {:copy => true, :attributes => {:start_date => date}})
+ @copy = @issue.move_to_project(Project.find(3), Tracker.find(2), {:copy => true, :attributes => {:start_date => date}})
assert_equal date, @copy.start_date
end
should "allow due date changes" do
date = Date.today
- @copy = @issue.move_to(Project.find(3), Tracker.find(2), {:copy => true, :attributes => {:due_date => date}})
+ @copy = @issue.move_to_project(Project.find(3), Tracker.find(2), {:copy => true, :attributes => {:due_date => date}})
assert_equal date, @copy.due_date
end
@@ -457,7 +458,7 @@ class IssueTest < ActiveSupport::TestCase
issue = Issue.find(12)
assert issue.recipients.include?(issue.author.mail)
# move the issue to a private project
- copy = issue.move_to(Project.find(5), Tracker.find(2), :copy => true)
+ copy = issue.move_to_project(Project.find(5), Tracker.find(2), :copy => true)
# author is not a member of project anymore
assert !copy.recipients.include?(copy.author.mail)
end