Adds some tests on project hierarchy methods.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/branches/work@2254 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
1 parent
77a72527d0
commit
c0e6711826
2 files changed
+51
-14
No files matched your search
+21
-8
@@ -11,7 +11,7 @@ projects_001:
|
|||||||
identifier: ecookbook
|
identifier: ecookbook
|
||||||
parent_id:
|
parent_id:
|
||||||
lft: 1
|
lft: 1
|
||||||
rgt: 8
|
rgt: 10
|
||||||
projects_002:
|
projects_002:
|
||||||
created_on: 2006-07-19 19:14:19 +02:00
|
created_on: 2006-07-19 19:14:19 +02:00
|
||||||
name: OnlineStore
|
name: OnlineStore
|
||||||
@@ -23,8 +23,8 @@ projects_002:
|
|||||||
is_public: false
|
is_public: false
|
||||||
identifier: onlinestore
|
identifier: onlinestore
|
||||||
parent_id:
|
parent_id:
|
||||||
lft: 9
|
lft: 11
|
||||||
rgt: 10
|
rgt: 12
|
||||||
projects_003:
|
projects_003:
|
||||||
created_on: 2006-07-19 19:15:21 +02:00
|
created_on: 2006-07-19 19:15:21 +02:00
|
||||||
name: eCookbook Subproject 1
|
name: eCookbook Subproject 1
|
||||||
@@ -36,8 +36,8 @@ projects_003:
|
|||||||
is_public: true
|
is_public: true
|
||||||
identifier: subproject1
|
identifier: subproject1
|
||||||
parent_id: 1
|
parent_id: 1
|
||||||
lft: 4
|
lft: 6
|
||||||
rgt: 5
|
rgt: 7
|
||||||
projects_004:
|
projects_004:
|
||||||
created_on: 2006-07-19 19:15:51 +02:00
|
created_on: 2006-07-19 19:15:51 +02:00
|
||||||
name: eCookbook Subproject 2
|
name: eCookbook Subproject 2
|
||||||
@@ -49,8 +49,8 @@ projects_004:
|
|||||||
is_public: true
|
is_public: true
|
||||||
identifier: subproject2
|
identifier: subproject2
|
||||||
parent_id: 1
|
parent_id: 1
|
||||||
lft: 6
|
lft: 8
|
||||||
rgt: 7
|
rgt: 9
|
||||||
projects_005:
|
projects_005:
|
||||||
created_on: 2006-07-19 19:15:51 +02:00
|
created_on: 2006-07-19 19:15:51 +02:00
|
||||||
name: Private child of eCookbook
|
name: Private child of eCookbook
|
||||||
@@ -63,5 +63,18 @@ projects_005:
|
|||||||
identifier: private-child
|
identifier: private-child
|
||||||
parent_id: 1
|
parent_id: 1
|
||||||
lft: 2
|
lft: 2
|
||||||
rgt: 3
|
rgt: 5
|
||||||
|
projects_006:
|
||||||
|
created_on: 2006-07-19 19:15:51 +02:00
|
||||||
|
name: Child of private child
|
||||||
|
updated_on: 2006-07-19 19:17:07 +02:00
|
||||||
|
projects_count: 0
|
||||||
|
id: 6
|
||||||
|
description: This is a public subproject of a private project
|
||||||
|
homepage: ""
|
||||||
|
is_public: true
|
||||||
|
identifier: project6
|
||||||
|
parent_id: 5
|
||||||
|
lft: 3
|
||||||
|
rgt: 4
|
||||||
|
|
||||||
@@ -45,12 +45,6 @@ class ProjectTest < Test::Unit::TestCase
|
|||||||
assert_equal "activerecord_error_blank", @ecookbook.errors.on(:name)
|
assert_equal "activerecord_error_blank", @ecookbook.errors.on(:name)
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_public_projects
|
|
||||||
public_projects = Project.find(:all, :conditions => ["is_public=?", true])
|
|
||||||
assert_equal 3, public_projects.length
|
|
||||||
assert_equal true, public_projects[0].is_public?
|
|
||||||
end
|
|
||||||
|
|
||||||
def test_archive
|
def test_archive
|
||||||
user = @ecookbook.members.first.user
|
user = @ecookbook.members.first.user
|
||||||
@ecookbook.archive
|
@ecookbook.archive
|
||||||
@@ -159,6 +153,36 @@ class ProjectTest < Test::Unit::TestCase
|
|||||||
assert_equal parent.children.sort_by(&:name), parent.children
|
assert_equal parent.children.sort_by(&:name), parent.children
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_parent
|
||||||
|
p = Project.find(6).parent
|
||||||
|
assert p.is_a?(Project)
|
||||||
|
assert_equal 5, p.id
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_ancestors
|
||||||
|
a = Project.find(6).ancestors
|
||||||
|
assert a.first.is_a?(Project)
|
||||||
|
assert_equal [1, 5], a.collect(&:id)
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_root
|
||||||
|
r = Project.find(6).root
|
||||||
|
assert r.is_a?(Project)
|
||||||
|
assert_equal 1, r.id
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_children
|
||||||
|
c = Project.find(1).children
|
||||||
|
assert c.first.is_a?(Project)
|
||||||
|
assert_equal [5, 3, 4], c.collect(&:id)
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_descendants
|
||||||
|
d = Project.find(1).descendants
|
||||||
|
assert d.first.is_a?(Project)
|
||||||
|
assert_equal [5, 6, 3, 4], d.collect(&:id)
|
||||||
|
end
|
||||||
|
|
||||||
def test_rolled_up_trackers
|
def test_rolled_up_trackers
|
||||||
parent = Project.find(1)
|
parent = Project.find(1)
|
||||||
parent.trackers = Tracker.find([1,2])
|
parent.trackers = Tracker.find([1,2])
|
||||||
|
|||||||
Reference in new issue
Block a user