mirror of
https://github.com/meineerde/redmine.git
synced 2026-03-12 04:03:08 +00:00
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:
parent
77a72527d0
commit
c0e6711826
29
nested_projects/test/fixtures/projects.yml
vendored
29
nested_projects/test/fixtures/projects.yml
vendored
@ -11,7 +11,7 @@ projects_001:
|
||||
identifier: ecookbook
|
||||
parent_id:
|
||||
lft: 1
|
||||
rgt: 8
|
||||
rgt: 10
|
||||
projects_002:
|
||||
created_on: 2006-07-19 19:14:19 +02:00
|
||||
name: OnlineStore
|
||||
@ -23,8 +23,8 @@ projects_002:
|
||||
is_public: false
|
||||
identifier: onlinestore
|
||||
parent_id:
|
||||
lft: 9
|
||||
rgt: 10
|
||||
lft: 11
|
||||
rgt: 12
|
||||
projects_003:
|
||||
created_on: 2006-07-19 19:15:21 +02:00
|
||||
name: eCookbook Subproject 1
|
||||
@ -36,8 +36,8 @@ projects_003:
|
||||
is_public: true
|
||||
identifier: subproject1
|
||||
parent_id: 1
|
||||
lft: 4
|
||||
rgt: 5
|
||||
lft: 6
|
||||
rgt: 7
|
||||
projects_004:
|
||||
created_on: 2006-07-19 19:15:51 +02:00
|
||||
name: eCookbook Subproject 2
|
||||
@ -49,8 +49,8 @@ projects_004:
|
||||
is_public: true
|
||||
identifier: subproject2
|
||||
parent_id: 1
|
||||
lft: 6
|
||||
rgt: 7
|
||||
lft: 8
|
||||
rgt: 9
|
||||
projects_005:
|
||||
created_on: 2006-07-19 19:15:51 +02:00
|
||||
name: Private child of eCookbook
|
||||
@ -63,5 +63,18 @@ projects_005:
|
||||
identifier: private-child
|
||||
parent_id: 1
|
||||
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)
|
||||
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
|
||||
user = @ecookbook.members.first.user
|
||||
@ecookbook.archive
|
||||
@ -159,6 +153,36 @@ class ProjectTest < Test::Unit::TestCase
|
||||
assert_equal parent.children.sort_by(&:name), parent.children
|
||||
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
|
||||
parent = Project.find(1)
|
||||
parent.trackers = Tracker.find([1,2])
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user