summaryrefslogtreecommitdiffstats
path: root/test/unit
diff options
context:
space:
mode:
authorGo MAEDA <maeda@farend.jp>2020-11-25 07:51:58 +0000
committerGo MAEDA <maeda@farend.jp>2020-11-25 07:51:58 +0000
commit2f43c315f36a88ca0251ff9d6ab46fa63f84839c (patch)
treeae824edc5d581391ead2eae068d51784a4820500 /test/unit
parent00c751a1a6ad5ae67d93b7687b4b1ff9a8c7307e (diff)
downloadredmine-2f43c315f36a88ca0251ff9d6ab46fa63f84839c.tar.gz
redmine-2f43c315f36a88ca0251ff9d6ab46fa63f84839c.zip
Create tracker by copy (#34258).
Patch by Takenori TAKAKI. git-svn-id: http://svn.redmine.org/redmine/trunk@20492 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'test/unit')
-rw-r--r--test/unit/tracker_test.rb28
1 files changed, 28 insertions, 0 deletions
diff --git a/test/unit/tracker_test.rb b/test/unit/tracker_test.rb
index 89a711fdd..1f3447da7 100644
--- a/test/unit/tracker_test.rb
+++ b/test/unit/tracker_test.rb
@@ -46,6 +46,34 @@ class TrackerTest < ActiveSupport::TestCase
assert_equal [2], project.rolled_up_trackers(false).visible(user).map(&:id)
end
+ def test_copy_from
+ tracker = Tracker.find(1)
+ copy = Tracker.new.copy_from(tracker)
+
+ assert_nil copy.id
+ assert_nil copy.position
+ assert_equal '', copy.name
+ assert_equal tracker.default_status_id, copy.default_status_id
+ assert_equal tracker.is_in_roadmap, copy.is_in_roadmap
+ assert_equal tracker.core_fields, copy.core_fields
+ assert_equal tracker.description, copy.description
+
+ copy.name = 'Copy'
+ assert copy.save
+ end
+
+ def test_copy_from_should_copy_custom_fields
+ tracker = Tracker.generate!(:custom_field_ids => [1, 2, 6])
+ copy = Tracker.new.copy_from(tracker)
+ assert_equal [1, 2, 6], copy.custom_field_ids.sort
+ end
+
+ def test_copy_from_should_copy_projects
+ tracker = Tracker.generate!(:project_ids => [1, 2, 3, 4, 5, 6])
+ copy = Tracker.new.copy_from(tracker)
+ assert_equal [1, 2, 3, 4, 5, 6], copy.project_ids.sort
+ end
+
def test_copy_workflows
source = Tracker.find(1)
rules_count = source.workflow_rules.count