To check out this repository please hg clone the following URL, or open the URL using EasyMercurial or your preferred Mercurial client.
root / .svn / pristine / 64 / 6405eab4a4b9b92dcff2e2c358f9c728d763c20e.svn-base @ 1297:0a574315af3e
History | View | Annotate | Download (1.07 KB)
| 1 |
require File.dirname(__FILE__) + '/../test_helper' |
|---|---|
| 2 |
|
| 3 |
module CollectiveIdea |
| 4 |
module Acts #:nodoc: |
| 5 |
module NestedSet #:nodoc: |
| 6 |
class AwesomeNestedSetTest < Test::Unit::TestCase |
| 7 |
include Helper |
| 8 |
fixtures :categories |
| 9 |
|
| 10 |
def test_nested_set_options |
| 11 |
expected = [ |
| 12 |
[" Top Level", 1], |
| 13 |
["- Child 1", 2], |
| 14 |
['- Child 2', 3], |
| 15 |
['-- Child 2.1', 4], |
| 16 |
['- Child 3', 5], |
| 17 |
[" Top Level 2", 6] |
| 18 |
] |
| 19 |
actual = nested_set_options(Category) do |c| |
| 20 |
"#{'-' * c.level} #{c.name}"
|
| 21 |
end |
| 22 |
assert_equal expected, actual |
| 23 |
end |
| 24 |
|
| 25 |
def test_nested_set_options_with_mover |
| 26 |
expected = [ |
| 27 |
[" Top Level", 1], |
| 28 |
["- Child 1", 2], |
| 29 |
['- Child 3', 5], |
| 30 |
[" Top Level 2", 6] |
| 31 |
] |
| 32 |
actual = nested_set_options(Category, categories(:child_2)) do |c| |
| 33 |
"#{'-' * c.level} #{c.name}"
|
| 34 |
end |
| 35 |
assert_equal expected, actual |
| 36 |
end |
| 37 |
|
| 38 |
end |
| 39 |
end |
| 40 |
end |
| 41 |
end |